Author: remy.maucherat(a)jboss.com
Date: 2008-09-01 07:36:53 -0400 (Mon, 01 Sep 2008)
New Revision: 761
Modified:
trunk/java/org/apache/jasper/compiler/Compiler.java
trunk/java/org/apache/jasper/compiler/JspUtil.java
trunk/java/org/apache/jasper/compiler/Node.java
trunk/java/org/apache/jasper/compiler/TagPluginManager.java
Log:
- 45691: Duplicate variables.
Modified: trunk/java/org/apache/jasper/compiler/Compiler.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Compiler.java 2008-09-01 11:36:23 UTC (rev 760)
+++ trunk/java/org/apache/jasper/compiler/Compiler.java 2008-09-01 11:36:53 UTC (rev 761)
@@ -146,9 +146,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: trunk/java/org/apache/jasper/compiler/JspUtil.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/JspUtil.java 2008-09-01 11:36:23 UTC (rev 760)
+++ trunk/java/org/apache/jasper/compiler/JspUtil.java 2008-09-01 11:36:53 UTC (rev 761)
@@ -59,8 +59,6 @@
private static final String OPEN_EXPR_XML = "%=";
private static final String CLOSE_EXPR_XML = "%";
- private static int tempSequenceNumber = 0;
-
//private static ExpressionEvaluatorImpl expressionEvaluator
//= new ExpressionEvaluatorImpl();
@@ -607,22 +605,6 @@
// }
}
- /**
- * Resets the temporary variable name.
- * (not thread-safe)
- */
- public static void resetTemporaryVariableName() {
- tempSequenceNumber = 0;
- }
-
- /**
- * Generates a new temporary variable name.
- * (not thread-safe)
- */
- public static String nextTemporaryVariableName() {
- return Constants.TEMP_VARIABLE_NAME_PREFIX + (tempSequenceNumber++);
- }
-
public static String coerceToPrimitiveBoolean(String s,
boolean isNamedAttribute) {
if (isNamedAttribute) {
Modified: trunk/java/org/apache/jasper/compiler/Node.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Node.java 2008-09-01 11:36:23 UTC (rev 760)
+++ trunk/java/org/apache/jasper/compiler/Node.java 2008-09-01 11:36:53 UTC (rev 761)
@@ -17,10 +17,10 @@
package org.apache.jasper.compiler;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import java.util.ArrayList;
import javax.el.ELContext;
import javax.el.ELException;
@@ -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();
+ }
+
+ }
}
/**
@@ -1866,7 +1884,7 @@
super(qName, ATTRIBUTE_ACTION, attrs, nonTaglibXmlnsAttrs,
taglibAttrs, start, parent);
- temporaryVariableName = JspUtil.nextTemporaryVariableName();
+ temporaryVariableName = getRoot().nextTemporaryVariableName();
if ("false".equals(this.getAttributeValue("trim"))) {
// (if null or true, leave default of true)
trim = false;
Modified: trunk/java/org/apache/jasper/compiler/TagPluginManager.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagPluginManager.java 2008-09-01 11:36:23 UTC
(rev 760)
+++ trunk/java/org/apache/jasper/compiler/TagPluginManager.java 2008-09-01 11:36:53 UTC
(rev 761)
@@ -191,7 +191,7 @@
}
public String getTemporaryVariableName() {
- return JspUtil.nextTemporaryVariableName();
+ return node.getRoot().nextTemporaryVariableName();
}
public void generateImport(String imp) {
Show replies by date