This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new 995625caa2 Fix BZ 69333 - remove unnecessary code from generated JSPs 995625caa2 is described below commit 995625caa294e5f29b56893db85291d2919d8035 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Sep 24 08:54:25 2024 +0100 Fix BZ 69333 - remove unnecessary code from generated JSPs --- java/org/apache/jasper/compiler/Generator.java | 39 +++++++--------------- .../apache/jasper/runtime/JspRuntimeLibrary.java | 10 +----- webapps/docs/changelog.xml | 7 ++++ 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index addaff3f6b..b3b5da5652 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -2163,7 +2163,7 @@ class Generator { saveScriptingVars(n, VariableInfo.AT_BEGIN); String tagHandlerClassName = tagHandlerClass.getCanonicalName(); - if (isPoolingEnabled && !(n.implementsJspIdConsumer())) { + if (usePooling(n)) { out.printin(tagHandlerClassName); out.print(" "); out.print(tagHandlerVar); @@ -2175,17 +2175,10 @@ class Generator { out.print(".get("); out.print(tagHandlerClassName); out.println(".class);"); - out.printin("boolean "); - out.print(tagHandlerVar); - out.println("_reused = false;"); } else { writeNewInstance(tagHandlerVar, tagHandlerClass); } - // 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); @@ -2372,32 +2365,18 @@ class Generator { out.printil("}"); } - // Print tag reuse - if (isPoolingEnabled && !(n.implementsJspIdConsumer())) { + if (usePooling(n)) { + // Print tag reuse out.printin(n.getTagHandlerPoolName()); out.print(".reuse("); out.print(tagHandlerVar); out.println(");"); - out.printin(tagHandlerVar); - out.println("_reused = true;"); - } - // Ensure clean-up takes place - // Use JspRuntimeLibrary to minimise code in _jspService() - out.popIndent(); - out.printil("} finally {"); - out.pushIndent(); - out.printin("org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag("); - out.print(tagHandlerVar); - out.print(", _jsp_getInstanceManager(), "); - if (isPoolingEnabled && !(n.implementsJspIdConsumer())) { + // Clean-up + out.printin("org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag("); out.print(tagHandlerVar); - out.println("_reused);"); - } else { - out.println("false);"); + out.println(", _jsp_getInstanceManager());"); } - out.popIndent(); - out.printil("}"); // Declare and synchronize AT_END scripting variables (must do this // outside the try/catch/finally block) @@ -2407,6 +2386,12 @@ class Generator { restoreScriptingVars(n, VariableInfo.AT_BEGIN); } + + private boolean usePooling(Node.CustomTag n) { + return isPoolingEnabled && !(n.implementsJspIdConsumer()); + } + + private void generateCustomDoTag(Node.CustomTag n, TagHandlerInfo handlerInfo, String tagHandlerVar) throws JasperException { diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java index d705e6cc93..1b6a75fae9 100644 --- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java +++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java @@ -1084,15 +1084,7 @@ public class JspRuntimeLibrary { } - public static void releaseTag(Tag tag, InstanceManager instanceManager, boolean reused) { - // Caller ensures pool is non-null if reuse is true - if (!reused) { - releaseTag(tag, instanceManager); - } - } - - - protected static void releaseTag(Tag tag, InstanceManager instanceManager) { + public static void releaseTag(Tag tag, InstanceManager instanceManager) { try { tag.release(); } catch (Throwable t) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index a0c40eb70f..4892221b5e 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -155,6 +155,13 @@ </fix> </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <fix> + <bug>69333</bug>: Remove unnecessary code from generated JSPs. (markt) + </fix> + </changelog> + </subsection> </section> <section name="Tomcat 10.1.30 (schultz)" rtext="2024-09-17"> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org