[
https://issues.apache.org/struts/browse/STR-3021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40745
]
Henri Yandell commented on STR-3021:
------------------------------------
The current doInclude method looks like this:
public void doInclude(String uri, PageContext pageContext, boolean flush)
throws IOException, ServletException {
try {
// perform include with new JSP 2.0 method that supports flushing
if (include != null) {
include.invoke(pageContext, new Object[]{uri,
Boolean.valueOf(flush)});
return;
}
} catch (IllegalAccessException e) {
log.debug("Could not find JSP 2.0 include method. Using old one.",
e);
} catch (InvocationTargetException e) {
log.debug("Unable to execute JSP 2.0 include method. Trying old
one.", e);
}
pageContext.include(uri);
}
It seems to me that you're throwing the baby out with the bathwater here. I do
agree though that the InvocationTargetException block is wrong. It should be
throwing its exception upwards rather than allowing the old include to be
executed.
So I'm thinking the new code should be something like:
public void doInclude(String uri, PageContext pageContext, boolean flush)
throws IOException, ServletException {
try {
// perform include with new JSP 2.0 method that supports flushing
if (include != null) {
include.invoke(pageContext, new Object[]{uri,
Boolean.valueOf(flush)});
return;
}
} catch (IllegalAccessException e) {
log.debug("Could not find JSP 2.0 include method. Using old one.",
e);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof ServletException){
throw ((ServletException)e.getCause());
}else if (e.getCause() instanceof IOException){
throw ((IOException)e.getCause());
}else{
throw new ServletException(e);
}
}
pageContext.include(uri);
}
Which should be good as long as Struts 1.3.x is JDK 1.4+. I've no idea if
flattening the chain when it's an IO or Servlet exception is good or bad.
The comments above aside...this looks like an obvious fix to me.
> Tiles insert is evaluated twice if JSP error occures
> ----------------------------------------------------
>
> Key: STR-3021
> URL: https://issues.apache.org/struts/browse/STR-3021
> Project: Struts 1
> Issue Type: Bug
> Components: Tiles
> Affects Versions: 1.3.5
> Environment: Tomcat 5.0
> Reporter: Thomas Wilhelm
> Fix For: 1.3.9, 1.4.0
>
>
> If an Exception is thrown in a tiles-included JSP the surrounding
> tiles-insert is processes twice. This most presumably due to a bug in
> TilesUtilImpl#doInclude(String uri, PageContext pageContext, boolean flush)
> where the InvocationTargetException is handled incorrectly. Every exception
> thrown from the executed inlcude-method will be throw wrapped into a
> InvocationTargetException so that include-method as well as
> pageContext.include(uri) is executed everytime a JSP-Error occures during an
> inlcude.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.