You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/06/18 13:51:07 UTC
[tomcat] branch 10.0.x updated: Fix BZ 65387 - fix regression in
generated code clean-up
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push:
new d6a869e Fix BZ 65387 - fix regression in generated code clean-up
d6a869e is described below
commit d6a869e681200a3d2c2279a789db8eb669021085
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 18 14:45:55 2021 +0100
Fix BZ 65387 - fix regression in generated code clean-up
Local variable out is required for TryCatchFinally tags
https://bz.apache.org/bugzilla/show_bug.cgi?id=65387
---
java/org/apache/jasper/compiler/Generator.java | 7 ++++---
test/org/apache/jasper/compiler/TestGenerator.java | 24 ++++++++++++++++++++--
test/webapp/WEB-INF/bugs.tld | 5 +++++
test/webapp/jsp/generator/customtag-02.jsp | 4 ++--
...-catch-finally.jsp => try-catch-finally-01.jsp} | 9 ++++----
...-catch-finally.jsp => try-catch-finally-02.jsp} | 5 +----
webapps/docs/changelog.xml | 9 ++++++++
7 files changed, 48 insertions(+), 15 deletions(-)
diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java
index 198632e..66ff231 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -1859,9 +1859,10 @@ class Generator {
if (!isTagFile) {
out.printil("jakarta.servlet.jsp.PageContext pageContext = _jspx_page_context;");
}
- // Only need to define out if the tag has a non-empty body or
- // uses <jsp:attribute>...</jsp:attribute> nodes
- if (!n.hasEmptyBody() || n.getNamedAttributeNodes().size() > 0) {
+ // Only need to define out if the tag has a non-empty body,
+ // implements TryCtachFinally or uses
+ // <jsp:attribute>...</jsp:attribute> nodes
+ if (!n.hasEmptyBody() || n.implementsTryCatchFinally() || n.getNamedAttributeNodes().size() > 0) {
out.printil("jakarta.servlet.jsp.JspWriter out = _jspx_page_context.getOut();");
}
generateLocalVariables(out, n);
diff --git a/test/org/apache/jasper/compiler/TestGenerator.java b/test/org/apache/jasper/compiler/TestGenerator.java
index d55e5f9..c37451c 100644
--- a/test/org/apache/jasper/compiler/TestGenerator.java
+++ b/test/org/apache/jasper/compiler/TestGenerator.java
@@ -434,6 +434,11 @@ public class TestGenerator extends TomcatBaseTest {
Assert.assertNotEquals(ids[0], ids[1]);
}
+ @Test
+ public void testTryCtachFinally02 () throws Exception {
+ doTestJsp("try-catch-finally-02.jsp");
+ }
+
public static class JspIdTag extends TagSupport implements JspIdConsumer {
private static final long serialVersionUID = 1L;
@@ -456,7 +461,7 @@ public class TestGenerator extends TomcatBaseTest {
}
}
- public static class TryCatchFinallyTag extends BodyTagSupport implements TryCatchFinally {
+ public static class TryCatchFinallyBodyTag extends BodyTagSupport implements TryCatchFinally {
private static final long serialVersionUID = 1L;
@@ -481,6 +486,21 @@ public class TestGenerator extends TomcatBaseTest {
}
}
+ public static class TryCatchFinallyTag extends TagSupport implements TryCatchFinally {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doCatch(Throwable t) throws Throwable {
+ // NO-OP
+ }
+
+ @Override
+ public void doFinally() {
+ // NO-OP
+ }
+ }
+
public static class TesterBodyTag extends BodyTagSupport {
private static final long serialVersionUID = 1L;
@@ -820,7 +840,7 @@ public class TestGenerator extends TomcatBaseTest {
@Test
public void testCustomTag01() throws Exception {
- doTestJsp("try-catch-finally.jsp");
+ doTestJsp("try-catch-finally-01.jsp");
}
@Test
diff --git a/test/webapp/WEB-INF/bugs.tld b/test/webapp/WEB-INF/bugs.tld
index 6428e87..1fff162 100644
--- a/test/webapp/WEB-INF/bugs.tld
+++ b/test/webapp/WEB-INF/bugs.tld
@@ -90,6 +90,11 @@
<body-content>JSP</body-content>
</tag>
<tag>
+ <name>TryCatchFinallyBodyTag</name>
+ <tag-class>org.apache.jasper.compiler.TestGenerator$TryCatchFinallyBodyTag</tag-class>
+ <body-content>JSP</body-content>
+ </tag>
+ <tag>
<name>TesterBodyTag</name>
<tag-class>org.apache.jasper.compiler.TestGenerator$TesterBodyTag</tag-class>
<body-content>JSP</body-content>
diff --git a/test/webapp/jsp/generator/customtag-02.jsp b/test/webapp/jsp/generator/customtag-02.jsp
index 14e33eb..57cd254 100644
--- a/test/webapp/jsp/generator/customtag-02.jsp
+++ b/test/webapp/jsp/generator/customtag-02.jsp
@@ -16,8 +16,8 @@
--%>
<%@ taglib uri="http://tomcat.apache.org/bugs" prefix="bugs" %>
<bugs:TesterBodyTag>
- <bugs:TryCatchFinallyTag>
+ <bugs:TryCatchFinallyBodyTag>
<bugs:TesterBodyTag>
</bugs:TesterBodyTag>
- </bugs:TryCatchFinallyTag>
+ </bugs:TryCatchFinallyBodyTag>
</bugs:TesterBodyTag>
\ No newline at end of file
diff --git a/test/webapp/jsp/generator/try-catch-finally.jsp b/test/webapp/jsp/generator/try-catch-finally-01.jsp
similarity index 85%
copy from test/webapp/jsp/generator/try-catch-finally.jsp
copy to test/webapp/jsp/generator/try-catch-finally-01.jsp
index 73ac9d8..d715c34 100644
--- a/test/webapp/jsp/generator/try-catch-finally.jsp
+++ b/test/webapp/jsp/generator/try-catch-finally-01.jsp
@@ -15,7 +15,8 @@
limitations under the License.
--%>
<%@ taglib uri="http://tomcat.apache.org/bugs" prefix="bugs" %>
-<bugs:TryCatchFinallyTag>
- <bugs:TryCatchFinallyTag>
- </bugs:TryCatchFinallyTag>
-</bugs:TryCatchFinallyTag>
+<bugs:TryCatchFinallyBodyTag>
+ <bugs:TryCatchFinallyBodyTag>
+ <p>OK</p>
+ </bugs:TryCatchFinallyBodyTag>
+</bugs:TryCatchFinallyBodyTag>
diff --git a/test/webapp/jsp/generator/try-catch-finally.jsp b/test/webapp/jsp/generator/try-catch-finally-02.jsp
similarity index 88%
rename from test/webapp/jsp/generator/try-catch-finally.jsp
rename to test/webapp/jsp/generator/try-catch-finally-02.jsp
index 73ac9d8..f2bd7d9 100644
--- a/test/webapp/jsp/generator/try-catch-finally.jsp
+++ b/test/webapp/jsp/generator/try-catch-finally-02.jsp
@@ -15,7 +15,4 @@
limitations under the License.
--%>
<%@ taglib uri="http://tomcat.apache.org/bugs" prefix="bugs" %>
-<bugs:TryCatchFinallyTag>
- <bugs:TryCatchFinallyTag>
- </bugs:TryCatchFinallyTag>
-</bugs:TryCatchFinallyTag>
+<bugs:TryCatchFinallyTag/>
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b1c87fe..510d2f4 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -177,6 +177,15 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <bug>65387</bug>: Correct a regression in the fix for <bug>65124</bug>
+ and restore the local definition of <code>out</code> for tags that
+ implement <code>TryCatchFinally</code>. (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Web applications">
<changelog>
<fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org