freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FREEMARKER-29) Stream closed Exception
Date Mon, 18 Jul 2016 18:08:20 GMT

    [ https://issues.apache.org/jira/browse/FREEMARKER-29?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15382736#comment-15382736
] 

Daniel Dekany commented on FREEMARKER-29:
-----------------------------------------

Also note this possibly related version history change in 2.3.23:

{quote}
Bug fixed: If a template "file" was successfully opened for reading, but then there was an
IOException during reading its content, the parser (JavaCC) acted like if the template "file"
was ended there, and the exception was suppressed. It's actually a JavaCC quirk that affects
many other JavaCC-based languages too, but now FreeMarker has added a workaround in the Template
constructor, and so now an exception will be thrown as expected.
{quote}

That is, perhaps the exception has occurred earlier too, but it has silently chopped the template.
Though it's strange that it instead of any "real"  {{IOException}} it dies in the {{BufferedReader}}
due to closed reader...

> Stream closed Exception
> -----------------------
>
>                 Key: FREEMARKER-29
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-29
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.23
>         Environment: Tomcat
>            Reporter: Christian Senkowski
>
> Hi,
> I'm getting Stream closed -exceptions flooding my log since 2.3.23 when using <#include>
> {quote}
> freemarker.core._MiscTemplateException: [... Exception message was already printed; see
it above ...]
>         at freemarker.core.Include.accept(Include.java:160)
>         at freemarker.core.Environment.visit(Environment.java:324)
>         at freemarker.core.Environment.process(Environment.java:302)
> […]
> Caused by: java.io.IOException: Stream closed
>         at java.io.StringReader.ensureOpen(StringReader.java:56)
>         at java.io.StringReader.read(StringReader.java:90)
>         at java.io.BufferedReader.read1(BufferedReader.java:210)
>         at java.io.BufferedReader.read(BufferedReader.java:286)
>         at freemarker.template.Template$LineTableBuilder.read(Template.java:701)
>         at freemarker.core.SimpleCharStream.FillBuff(SimpleCharStream.java:107)
>         at freemarker.core.SimpleCharStream.readChar(SimpleCharStream.java:188)
>         at freemarker.core.SimpleCharStream.BeginToken(SimpleCharStream.java:129)
>         at freemarker.core.FMParserTokenManager.getNextToken(FMParserTokenManager.java:7190)
>         at freemarker.core.FMParser.jj_scan_token(FMParser.java:5131)
>         at freemarker.core.FMParser.jj_3_16(FMParser.java:3812)
>         at freemarker.core.FMParser.jj_2_16(FMParser.java:3549)
>         at freemarker.core.FMParser.Root(FMParser.java:3427)
>         at freemarker.template.Template.<init>(Template.java:208)
>         at freemarker.cache.TemplateCache.loadTemplate(TemplateCache.java:495)
>         at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:409)
>         at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:261)
>         at freemarker.template.Configuration.getTemplate(Configuration.java:1786)
>         at freemarker.core.Environment.getTemplateForInclusion(Environment.java:2044)
>         at freemarker.core.Include.accept(Include.java:158)
>         ... 31 more
> {quote}
> I am extending the Freemarker Config
> {quote}
>  public static class FreemarkerConfig extends Configuration {
>         public FreemarkerConfig() {
>             super(FREEMARKER_VERSION);
>             setObjectWrapper(new DefaultObjectWrapper(FREEMARKER_VERSION));
>             setCacheStorage(new FreemarkerCacheStorage());
>             setTemplateExceptionHandler(new FreemarkerTemplateExceptionHandler());
>             setTemplateUpdateDelayMilliseconds(Integer.MAX_VALUE);
>             setOutputEncoding("utf-8");
>             setLocalizedLookup(false);
>             // create static stuff to access utility class in freemarker
>             final BeansWrapper wrapper = new BeansWrapperBuilder(FREEMARKER_VERSION).build();
>             TemplateHashModel staticModels = wrapper.getStaticModels();
>             try {
>                 TemplateHashModel util = (TemplateHashModel) staticModels.get(Util.class.getName());
>                 setSharedVariable("util", util);
>             } catch (final TemplateModelException e) {
>                 throw new IllegalStateException(e);
>             }
>         }
>     }
> {quote}
> If you need any further informations please let me know. Any help highly appreciated.
Changing everything back to 2.3.20 let this exception disappear.
> Thanks,
> Diceme7



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message