Author: remm Date: Thu Dec 22 09:14:53 2016 New Revision: 1775596 URL: http://svn.apache.org/viewvc?rev=1775596&view=rev Log: 60497: Restore previous tag reuse behavior following the use of try/finally. Improve the error handling for simple tags to ensure that the tag is 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=1775596&r1=1775595&r2=1775596&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Thu Dec 22 09:14:53 2016 @@ -2395,6 +2395,9 @@ class Generator { out.print(".get("); out.print(tagHandlerClassName); out.println(".class);"); + out.printin("boolean "); + out.print(n.getTagHandlerPoolName()); + out.println("_reused = false;"); } else { writeNewInstance(tagHandlerVar, tagHandlerClassName); } @@ -2600,19 +2603,32 @@ class Generator { out.printil("}"); } - // Ensure clean-up takes place - out.popIndent(); - out.printil("} finally {"); - out.pushIndent(); + // Print tag reuse 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); + out.printin(n.getTagHandlerPoolName()); + out.println("_reused = true;"); + } + + // Ensure clean-up takes place + out.popIndent(); + out.printil("} finally {"); + out.pushIndent(); + if (isPoolingEnabled && !(n.implementsJspIdConsumer())) { + out.printin("if (!"); + out.print(n.getTagHandlerPoolName()); + out.println("_reused) {"); + out.pushIndent(); + } + out.printin(tagHandlerVar); + out.println(".release();"); + writeDestroyInstance(tagHandlerVar); + if (isPoolingEnabled && !(n.implementsJspIdConsumer())) { + out.popIndent(); + out.printil("}"); } out.popIndent(); out.printil("}"); @@ -2643,6 +2659,9 @@ class Generator { String tagHandlerClassName = tagHandlerClass.getCanonicalName(); writeNewInstance(tagHandlerVar, tagHandlerClassName); + out.printil("try {"); + out.pushIndent(); + generateSetters(n, tagHandlerVar, handlerInfo, true); // JspIdConsumer (after context has been set) @@ -2694,9 +2713,16 @@ class Generator { declareScriptingVars(n, VariableInfo.AT_END); syncScriptingVars(n, VariableInfo.AT_END); + out.popIndent(); + out.printil("} finally {"); + out.pushIndent(); + // Resource injection writeDestroyInstance(tagHandlerVar); + out.popIndent(); + out.printil("}"); + n.setEndJavaLine(out.getJavaLine()); } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1775596&r1=1775595&r2=1775596&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Dec 22 09:14:53 2016 @@ -100,9 +100,19 @@ </subsection> <subsection name="Jasper"> <changelog> - Implement a simpler JSP file encoding detector that delegates XML prolog - encoding detection to the JRE rather than using a custom XML parser. - (markt) + <update> + Implement a simpler JSP file encoding detector that delegates XML prolog + encoding detection to the JRE rather than using a custom XML parser. + (markt) + </update> + <fix> + <bug>60497</bug>: Restore previous tag reuse behavior following the use + of try/finally. (remm) + </fix> + <fix> + Improve the error handling for simple tags to ensure that the tag is + released and destroyed once used. (remm) + </fix> </changelog> </subsection> <subseciton name="WebSocket"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org