This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new 4aab46d Partial fix for BZ 65124. Only generate local out variable when required 4aab46d is described below commit 4aab46d425e26dd6448665c74f0956e01c9fa8fb Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue May 18 11:22:04 2021 +0100 Partial fix for BZ 65124. Only generate local out variable when required https://bz.apache.org/bugzilla/show_bug.cgi?id=65124 --- java/org/apache/jasper/compiler/Generator.java | 8 ++++++-- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index 4c228e8..92ccaf6 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -1845,9 +1845,13 @@ class Generator { // Initialize local variables used in this method. if (!isTagFile) { - out.printil("jakarta.servlet.jsp.PageContext pageContext = _jspx_page_context;"); + out.printil("final 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) { + out.printil("jakarta.servlet.jsp.JspWriter out = _jspx_page_context.getOut();"); } - out.printil("jakarta.servlet.jsp.JspWriter out = _jspx_page_context.getOut();"); generateLocalVariables(out, n); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 20a366a..173e8cd 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -131,6 +131,11 @@ Refactor use of internal <code>ChildInfo</code> class to use compile time type checking rather than run time type checking. (markt) </scode> + <fix> + <bug>65124</bug>: Partial fix. When generating Java source code to call + a tag handler, only define the local variable <code>JspWriter out</code> + when it is going to be used. (markt) + </fix> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org