tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r707745 - in /tomcat/tc6.0.x/trunk: ./ java/org/apache/jasper/compiler/ webapps/docs/
Date Fri, 24 Oct 2008 21:03:23 GMT
Author: markt
Date: Fri Oct 24 14:03:23 2008
New Revision: 707745

URL: http://svn.apache.org/viewvc?rev=707745&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45691
Prevent generation of duplicate variable names.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Node.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=707745&r1=707744&r2=707745&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Fri Oct 24 14:03:23 2008
@@ -73,12 +73,6 @@
   -0: remm: configuring this is useless (esp on Windows, only the default behavior gives
acceptable performance)
   -1: 
 
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45691
-  http://svn.apache.org/viewvc?rev=690693&view=rev
-  NB: Methods deleted in JspUtil to be deprecated rather than deleted
-  +1: markt, remm, fhanik
-  -1:
-
 * ETag improvement: https://issues.apache.org/bugzilla/show_bug.cgi?id=45735
   +1: remm, markt, rjung
   -1: 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=707745&r1=707744&r2=707745&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Compiler.java Fri Oct 24 14:03:23
2008
@@ -145,10 +145,6 @@
 
         ServletWriter writer = null;
         try {
-
-            // Reset the temporary variable counter for the generator.
-            JspUtil.resetTemporaryVariableName();
-
             // Parse the file
             ParserController parserCtl = new ParserController(ctxt, this);
             pageNodes = parserCtl.parse(ctxt.getJspFile());

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java?rev=707745&r1=707744&r2=707745&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/JspUtil.java Fri Oct 24 14:03:23
2008
@@ -610,6 +610,7 @@
     /**
      * Resets the temporary variable name.
      * (not thread-safe)
+     * @deprecated
      */
     public static void resetTemporaryVariableName() {
         tempSequenceNumber = 0;
@@ -618,6 +619,7 @@
     /**
      * Generates a new temporary variable name.
      * (not thread-safe)
+     * @deprecated
      */
     public static String nextTemporaryVariableName() {
         return Constants.TEMP_VARIABLE_NAME_PREFIX + (tempSequenceNumber++);
@@ -1141,4 +1143,4 @@
 
         return buf.toString();
     }
-}
\ No newline at end of file
+}

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Node.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Node.java?rev=707745&r1=707744&r2=707745&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Node.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Node.java Fri Oct 24 14:03:23 2008
@@ -39,6 +39,7 @@
 import javax.servlet.jsp.tagext.TryCatchFinally;
 import javax.servlet.jsp.tagext.VariableInfo;
 
+import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.compiler.tagplugin.TagPluginContext;
 import org.xml.sax.Attributes;
@@ -470,6 +471,11 @@
         private boolean isBomPresent;
 
         /*
+         * Sequence number for temporary variables.
+         */
+        private int tempSequenceNumber = 0;
+
+        /*
          * Constructor.
          */
         Root(Mark start, Node parent, boolean isXmlSyntax) {
@@ -548,6 +554,18 @@
         public Root getParentRoot() {
             return parentRoot;
         }
+        
+        /**
+         * Generates a new temporary variable name.
+         */
+        public String nextTemporaryVariableName() {
+            if (parentRoot == null) {
+                return Constants.TEMP_VARIABLE_NAME_PREFIX + (tempSequenceNumber++);
+            } else {
+                return parentRoot.nextTemporaryVariableName();
+            }
+            
+        }
     }
 
     /**
@@ -1913,7 +1931,7 @@
          */
         public String getTemporaryVariableName() {
             if (temporaryVariableName == null) {
-                temporaryVariableName = JspUtil.nextTemporaryVariableName();
+                temporaryVariableName = getRoot().nextTemporaryVariableName();
             }
             return temporaryVariableName;
         }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java?rev=707745&r1=707744&r2=707745&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java Fri Oct 24
14:03:23 2008
@@ -150,91 +150,91 @@
 	    n.setAtSTag(curNodes);
 	    n.setUseTagPlugin(true);
 	    pluginAttributes = new HashMap();
-	}
+        }
 
-	public TagPluginContext getParentContext() {
-	    Node parent = node.getParent();
-	    if (! (parent instanceof Node.CustomTag)) {
-		return null;
-	    }
-	    return ((Node.CustomTag) parent).getTagPluginContext();
-	}
-
-	public void setPluginAttribute(String key, Object value) {
-	    pluginAttributes.put(key, value);
-	}
-
-	public Object getPluginAttribute(String key) {
-	    return pluginAttributes.get(key);
-	}
-
-	public boolean isScriptless() {
-	    return node.getChildInfo().isScriptless();
-	}
-
-	public boolean isConstantAttribute(String attribute) {
-	    Node.JspAttribute attr = getNodeAttribute(attribute);
-	    if (attr == null)
-		return false;
-	    return attr.isLiteral();
-	}
+        public TagPluginContext getParentContext() {
+            Node parent = node.getParent();
+            if (! (parent instanceof Node.CustomTag)) {
+                return null;
+            }
+            return ((Node.CustomTag) parent).getTagPluginContext();
+        }
+
+        public void setPluginAttribute(String key, Object value) {
+            pluginAttributes.put(key, value);
+        }
+
+        public Object getPluginAttribute(String key) {
+            return pluginAttributes.get(key);
+        }
+
+        public boolean isScriptless() {
+            return node.getChildInfo().isScriptless();
+        }
 
-	public String getConstantAttribute(String attribute) {
-	    Node.JspAttribute attr = getNodeAttribute(attribute);
+        public boolean isConstantAttribute(String attribute) {
+            Node.JspAttribute attr = getNodeAttribute(attribute);
             if (attr == null)
-		return null;
-	    return attr.getValue();
-	}
-
-	public boolean isAttributeSpecified(String attribute) {
-	    return getNodeAttribute(attribute) != null;
-	}
-
-	public String getTemporaryVariableName() {
-	    return JspUtil.nextTemporaryVariableName();
-	}
-
-	public void generateImport(String imp) {
-	    pageInfo.addImport(imp);
-	}
-
-	public void generateDeclaration(String id, String text) {
-	    if (pageInfo.isPluginDeclared(id)) {
-		return;
-	    }
-	    curNodes.add(new Node.Declaration(text, node.getStart(), null));
-	}
-
-	public void generateJavaSource(String sourceCode) {
-	    curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(),
-					    null));
-	}
-
-	public void generateAttribute(String attributeName) {
-	    curNodes.add(new Node.AttributeGenerator(node.getStart(),
-						     attributeName,
-						     node));
-	}
-
-	public void dontUseTagPlugin() {
-	    node.setUseTagPlugin(false);
-	}
-
-	public void generateBody() {
-	    // Since we'll generate the body anyway, this is really a nop, 
-	    // except for the fact that it lets us put the Java sources the
-	    // plugins produce in the correct order (w.r.t the body).
-	    curNodes = node.getAtETag();
-	}
-
-	private Node.JspAttribute getNodeAttribute(String attribute) {
-	    Node.JspAttribute[] attrs = node.getJspAttributes();
-	    for (int i=0; attrs != null && i < attrs.length; i++) {
-		if (attrs[i].getName().equals(attribute)) {
-		    return attrs[i];
-		}
-	    }
-	    return null;
-	}
+                return false;
+            return attr.isLiteral();
+        }
+
+        public String getConstantAttribute(String attribute) {
+            Node.JspAttribute attr = getNodeAttribute(attribute);
+            if (attr == null)
+                return null;
+            return attr.getValue();
+        }
+
+        public boolean isAttributeSpecified(String attribute) {
+            return getNodeAttribute(attribute) != null;
+        }
+
+        public String getTemporaryVariableName() {
+            return node.getRoot().nextTemporaryVariableName();
+        }
+
+        public void generateImport(String imp) {
+            pageInfo.addImport(imp);
+        }
+
+        public void generateDeclaration(String id, String text) {
+            if (pageInfo.isPluginDeclared(id)) {
+                return;
+            }
+            curNodes.add(new Node.Declaration(text, node.getStart(), null));
+        }
+
+        public void generateJavaSource(String sourceCode) {
+            curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(),
+                                            null));
+        }
+
+        public void generateAttribute(String attributeName) {
+            curNodes.add(new Node.AttributeGenerator(node.getStart(),
+                                                     attributeName,
+                                                     node));
+        }
+
+        public void dontUseTagPlugin() {
+            node.setUseTagPlugin(false);
+        }
+
+        public void generateBody() {
+            // Since we'll generate the body anyway, this is really a nop, 
+            // except for the fact that it lets us put the Java sources the
+            // plugins produce in the correct order (w.r.t the body).
+            curNodes = node.getAtETag();
+        }
+
+        private Node.JspAttribute getNodeAttribute(String attribute) {
+            Node.JspAttribute[] attrs = node.getJspAttributes();
+            for (int i=0; attrs != null && i < attrs.length; i++) {
+                if (attrs[i].getName().equals(attribute)) {
+                    return attrs[i];
+                }
+            }
+            return null;
+        }
     }
 }

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=707745&r1=707744&r2=707745&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Fri Oct 24 14:03:23 2008
@@ -136,6 +136,10 @@
       <fix>
         <bug>45666</bug>: Prevent infinite loop on include. (markt)
       </fix>
+      <fix>
+        <bug>45691</bug>: Prevent generation of duplicate variable names when
+        generating code for JSPs. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message