https://issues.apache.org/bugzilla/show_bug.cgi?id=13731
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 16 Dec 2010 23:35:17 +0000 (23:35 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 16 Dec 2010 23:35:17 +0000 (23:35 +0000)
Make variables in <code>_jspService()</code> method final where possible.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1050229 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/Generator.java
webapps/docs/changelog.xml

index 0a52ec6..6435378 100644 (file)
@@ -614,23 +614,20 @@ class Generator {
         // Class variable declarations
         genPreambleClassVariableDeclarations();
 
-        // Constructor
-        // generateConstructor(className);
-
         // Methods here
         genPreambleMethods();
 
         // Now the service method
         out.printin("public void ");
         out.print(serviceMethodName);
-        out.println("(HttpServletRequest request, HttpServletResponse response)");
+        out.println("(final HttpServletRequest request, final HttpServletResponse response)");
         out.println("        throws java.io.IOException, ServletException {");
 
         out.pushIndent();
         out.println();
 
         // Local variable declarations
-        out.printil("PageContext pageContext = null;");
+        out.printil("final PageContext pageContext;");
 
         if (pageInfo.isSession())
             out.printil("HttpSession session = null;");
@@ -644,10 +641,10 @@ class Generator {
             out.printil("}");
         }
 
-        out.printil("ServletContext application = null;");
-        out.printil("ServletConfig config = null;");
+        out.printil("final ServletContext application;");
+        out.printil("final ServletConfig config;");
         out.printil("JspWriter out = null;");
-        out.printil("Object page = this;");
+        out.printil("final Object page = this;");
 
         out.printil("JspWriter _jspx_out = null;");
         out.printil("PageContext _jspx_page_context = null;");
@@ -667,8 +664,7 @@ class Generator {
             out.printil("response.addHeader(\"X-Powered-By\", \"JSP/2.1\");");
         }
 
-        out
-                .printil("pageContext = _jspxFactory.getPageContext(this, request, response,");
+        out.printil("pageContext = _jspxFactory.getPageContext(this, request, response,");
         out.printin("\t\t\t");
         out.print(quote(pageInfo.getErrorPage()));
         out.print(", " + pageInfo.isSession());
index 55f8f38..fa68791 100644 (file)
   </subsection>
   <subsection name="Jasper">
     <changelog>
+      <add>
+        <bug>13731</bug>: Make variables in <code>_jspService()</code> method
+        final where possible. (markt)
+      </add>
       <fix>
         <bug>50408</bug>: Fix <code>NoSuchMethodException</code> when using
         scoped variables with EL method invocation. (markt)