Author: markt
Date: Tue Jul 26 11:49:28 2016
New Revision: 1754111
URL: http://svn.apache.org/viewvc?rev=1754111&view=rev
Log:
Improve the error handling for custom tags to ensure that the tag is returned
to the pool or released and destroyed once used.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java?rev=1754111&r1=1754110&r2=1754111&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Tue Jul 26
11:49:28 2016
@@ -2399,6 +2399,10 @@ class Generator {
writeNewInstance(tagHandlerVar, tagHandlerClassName);
}
+ // Wrap use of tag in try/finally to ensure clean-up takes place
+ out.printil("try {");
+ out.pushIndent();
+
// includes setting the context
generateSetters(n, tagHandlerVar, handlerInfo, false);
@@ -2559,18 +2563,6 @@ class Generator {
out.print(tagHandlerVar);
out.println(".doEndTag() ==
javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {");
out.pushIndent();
- if (!n.implementsTryCatchFinally()) {
- if (isPoolingEnabled && !(n.implementsJspIdConsumer())) {
- out.printin(n.getTagHandlerPoolName());
- out.print(".reuse(");
- out.print(tagHandlerVar);
- out.println(");");
- } else {
- out.printin(tagHandlerVar);
- out.println(".release();");
- writeDestroyInstance(tagHandlerVar);
- }
- }
if (isTagFile || isFragment) {
out.printil("throw new
javax.servlet.jsp.SkipPageException();");
} else {
@@ -2603,6 +2595,15 @@ class Generator {
out.println(".doFinally();");
}
+ if (n.implementsTryCatchFinally()) {
+ out.popIndent();
+ out.printil("}");
+ }
+
+ // Ensure clean-up takes place
+ out.popIndent();
+ out.printil("} finally {");
+ out.pushIndent();
if (isPoolingEnabled && !(n.implementsJspIdConsumer())) {
out.printin(n.getTagHandlerPoolName());
out.print(".reuse(");
@@ -2613,11 +2614,8 @@ class Generator {
out.println(".release();");
writeDestroyInstance(tagHandlerVar);
}
-
- if (n.implementsTryCatchFinally()) {
- out.popIndent();
- out.printil("}");
- }
+ out.popIndent();
+ out.printil("}");
// Declare and synchronize AT_END scripting variables (must do this
// outside the try/catch/finally block)
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1754111&r1=1754110&r2=1754111&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Jul 26 11:49:28 2016
@@ -80,6 +80,10 @@
used in the XML prolog matches the encoding used to write the contents
of the file. (markt)
</fix>
+ <fix>
+ Improve the error handling for custom tags to ensure that the tag is
+ returned to the pool or released and destroyed once used. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Web applications">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]