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

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


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

commit bf9cab350b0b12256c17aa7e958109e56bff711d
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 efbf17588a..f9425d9173 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2144,7 +2144,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);
@@ -2156,17 +2156,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);
 
@@ -2353,32 +2346,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)
@@ -2388,6 +2367,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 eb16032d03..246567ac36 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 11.0.0-M26 (markt)" 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