This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 397ea8b746 Fix BZ 69333 - remove unnecessary code from generated JSPs
397ea8b746 is described below

commit 397ea8b7461bdeaad8b7f005fca3cdd31df4be2a
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 6264782134..814c8bb9fe 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2395,7 +2395,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);
@@ -2407,17 +2407,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);
 
@@ -2604,32 +2597,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)
@@ -2639,6 +2618,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 5c674eee4f..d9db53cea3 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 bbc8ca1e61..3145c557cb 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -150,6 +150,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 9.0.95 (remm)" rtext="release in progress">
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to