Discussion:
unknown
1970-01-01 00:00:00 UTC
Permalink
<span style=3D"font-family:arial,sans-serif;font-size:13.333333969116211px"=
TemplateLoader.</span><br></div><div><span style=3D"font-family:arial,sans=
-serif;font-size:13.333333969116211px">Yeah, i returned a closed stringRead=
er. What an omg-mistake !</span></div>

<div><span style=3D"font-family:arial,sans-serif;font-size:13.3333339691162=
11px">Now i have changed it to close the &#39;wrapped&#39; reader instead.<=
/span></div><div><span style=3D"font-family:arial,sans-serif;font-size:13.3=
33333969116211px">Thanks so much for the guides.</span></div>

<div><span style=3D"font-family:arial,sans-serif;font-size:13.3333339691162=
11px"><br></span></div></div><div class=3D"gmail_extra"><div><div class=3D"=
h5"><br><br><div class=3D"gmail_quote">On Thu, Mar 14, 2013 at 3:06 AM, Dan=
iel Dekany <span dir=3D"ltr">&lt;<a href=3D"mailto:***@freemail.hu" tar=
get=3D"_blank">***@freemail.hu</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Wednesday, March 13, 2013, 3:42:36 AM, Alber=
t Kam wrote:<br>
<br>
[snip]<br> <div>&gt; I tried closing the reader and catching and logging the exception=
<br>
&gt; instead of just using IOTools.closeQuietly(),<br>
&gt; and notices that there&#39;s no exception happening, and still gave me=
the empty page.<br>
&gt; Commenting the close reader section gave me back the output.<br>
<br>
</div>Are you returning a StringReader before calling<br>
IOTools.closeQuietly()on *another* reader? Because then this<br>
phenomenon it doesn&#39;t make any sense.<br>
<br>
[snip]<br> <div>&gt; Aha, maybe that&#39;s the reason it gave me the empty output.<br>
&gt; According to<br>
&gt; <a href=3D"http://docs.oracle.com/javase/7/docs/api/java/io/StringRead=
er.html#close()" target=3D"_blank">http://docs.oracle.com/javase/7/docs/api=
/java/io/StringReader.html#close()</a><br>
&gt; &quot;Closes the stream and releases any system resources associated w=
ith it.<br>
&gt; Once the stream has been closed, further read(), ready(), mark(),<br>
&gt; or reset() invocations will throw an IOException. Closing a<br>
&gt; previously closed stream has no effect.&quot;<br>
&gt; Maybe the caller of the closed-reader got an IOException somewhere and=
hence, the empty output ?<br>
<br>
</div>You aren&#39;t supposed to close the StringReader inside the<br>
TemplateLoader. You should close the *other* reader, the one that you<br>
don&#39;t return. Also, if FreeMarker gives empty output when an<br>
IOException occurs, that&#39;s a bug. But I hope it doesn&#39;t do that, it=
&#39;s<br>
rather the framework that calls it that suppresses that exception<br>
instead of giving a HTTP 500.<br>
<br>
[snip]<br> <div>&gt; I actually have switched back to the normal FileTemplateLoader<br=
&gt; without wrapping the escape directive for several reasons :<br>
&gt;<br>
&gt; - I actually make use of functions for URLs generation.<br>
&gt; =A0 And it&#39;s ugly to see the noescape tags wrapping every link cal=
ls, some thing like :<br>
&gt; =A0 &lt;#noescape&gt;${url.home(&quot;Return to main page&quot;)}&lt;/=
#noescape&gt;<br>
&gt; =A0 I prefer using ?html as needed<br>
<br>
</div>It&#39;s a strange coincidence that you say this just after 2 weeks o=
r so<br>
after I have proposed #p. It addresses exactly this annoyance, but I<br>
don&#39;t remember anybody but myself ever brought this up, till now.<br>
Anyway, it will be in 2.3.20 most probably.<br>
<div><br>
&gt; - Because i am using JBoss Tools for the freemarker editor (which<br>
&gt; does help me in parsing error detection, highlighting, etc), it<br>
&gt; errors the line of every noescape because it&#39;s not inside an escap=
e<br>
&gt; directive, which gives me the tension i dont need.<br>
<br>
</div>This will also be solved by #p, since then you won&#39;t need #noescp=
e<br>
anymore. Indeed, I might as well deprecate #noescape then.<br>
<div><br>
&gt; =A0And thank you for the wrapReader sharing, i will add it to my<br>
&gt; library in case i find a use of it in the future.<br>
&gt;<br>
&gt; Regards from Jakarta,<br>
&gt; Albert Kam<br>
<br>
--<br>
</div><div><div>Best regards,<br>
=A0Daniel Dekany<br>
<br>
<br>
---------------------------------------------------------------------------=
---<br>
Everyone hates slow websites. So do we.<br>
Make your web apps faster with AppDynamics<br>
Download AppDynamics Lite for free today:<br>
<a href=3D"http://p.sf.net/sfu/appdyn_d2d_mar" target=3D"_blank">http://p.s=
f.net/sfu/appdyn_d2d_mar</a><br>
_______________________________________________<br>
FreeMarker-user mailing list<br>
<a href=3D"mailto:FreeMarker-***@lists.sourceforge.net" target=3D"_blank">=
FreeMarker-***@lists.sourceforge.net</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/freemarker-user" ta=
rget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/freemarker-use=
r</a><br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div></div><=
/div><div class=3D"im">-- <br>Do not pursue the past. Do not lose yourself =
in the future. <br>The past no longer is. The future has not yet come. <br>
Looking deeply at life as it is in the very here and now, <br>
the practitioner dwells in stability and freedom.<br>(Thich Nhat Hanh)
</div></div>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Do not pursu=
e the past. Do not lose yourself in the future. <br>The past no longer is. =
The future has not yet come. <br>Looking deeply at life as it is in the ver=
y here and now, <br>
the practitioner dwells in stability and freedom.<br>(Thich Nhat Hanh)
</div>

--14dae9340e5b82a55404d7d99e34--

Loading...