This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 4e16d8e30d Fix BZ 69333 - remove unnecessary code from generated JSPs
4e16d8e30d is described below
commit 4e16d8e30d2215ca9680edfa29feeaef5e26e91f
Author: Mark Thomas <[email protected]>
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 +-----
2 files changed, 13 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) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]