[
https://issues.apache.org/struts/browse/WW-2071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44926#action_44926
]
DavidZaz commented on WW-2071:
------------------------------
Lines 480-492 in UIBean.java illustrate the problem:
480 public boolean end(Writer writer, String body) {
481 evaluateParams();
482 try {
483 super.end(writer, body, false);
484 mergeTemplate(writer, buildTemplateName(template,
getDefaultTemplate()));
485 } catch (Exception e) {
486 LOG.error("error when rendering", e);
487 }
488 finally {
489 popComponentStack();
490 }
491
492 return false;
In the catch block, the exception is logged, but no special value is returned
to indicate failure. The remainder of the JSP page will still be parsed and the
same exception gets thrown multiple times. This occurs since UIBean.end always
returns 'false' and UIBean.MergeTemplate (see line 530) does not even check the
return result from UIBean.end.
To reproduce this problem, use the following test case:
1. Create a Struts action which populates a very large List (maybe 5-10
thousand elements).
2. Create a JSP page which iterates through the List and displays the elements
on the page.
3. While the JSP page is loading (but before it is complete), navigate away
from the loading page.
This causes the output stream to be closed. Yet UIBean.end keeps calling
super.end(writer, body, false) on the closed writer object. The exception is
then caught and displayed in my server log. Since no failure value is returned,
Struts continues iterating over the remainder of the List and logs an exception
for each list element. For large lists, this produces a ridiculous amount of
log data by repeatedly printing out the same exception.
Would it be possible to make this error handling more robust so that Struts
would realize that the UIBean.end method is failing and stop retrying the same
operation? I tried to work around this bug by writing my own
ExceptionMappingInterceptor. My interceptor was able to catch the exception,
but not until after UIBean.end had produced thousands of log entries. The best
solution would be to fix UIBean.end and UIBean.MergeTemplate to take
appropriate action when an exception is thrown.
Here is a sample stacktrace:
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: ERROR - UIBean.end(486)
| error when rendering
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: java.io.IOException:
WEB8004: Error flushing the output stream
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
com.iplanet.ias.web.connector.nsapi.NSAPIConnector.flush(NSAPIConnector.java:743)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
com.iplanet.ias.web.connector.nsapi.NSAPIResponseStream.flush(NSAPIResponseStream.java:97)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
com.iplanet.ias.web.connector.nsapi.NSAPIResponse.flushBuffer(NSAPIResponse.java:131)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java:219)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
javax.servlet.ServletResponseWrapper.flushBuffer(ServletResponseWrapper.java:189)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:227)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
freemarker.core.Environment.process(Environment.java:178)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
freemarker.template.Template.process(Template.java:232)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:168)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:530)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
org.apache.struts2.components.UIBean.end(UIBean.java:484)
[06/Nov/2008:09:19:01] info ( 4768): CORE3282: stdout: at
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
> UIBean.end does not fail when an exception happens
> --------------------------------------------------
>
> Key: WW-2071
> URL: https://issues.apache.org/struts/browse/WW-2071
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Tags
> Affects Versions: 2.1.0
> Reporter: Antonio Petrelli
> Fix For: 2.1.3
>
>
> UIBean.end does not fail if something wrong happens in calling "super.end" or
> when merging template.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.