Author: mmillson
Date: 2010-07-07 16:47:49 -0400 (Wed, 07 Jul 2010)
New Revision: 1502
Modified:
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Compiler.java
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/JspUtil.java
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Node.java
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/TagPluginManager.java
Log:
Fix Jasper duplicate variable names for [JBPAPP-4574].
Modified:
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Compiler.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Compiler.java 2010-07-07
20:38:35 UTC (rev 1501)
+++
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Compiler.java 2010-07-07
20:47:49 UTC (rev 1502)
@@ -144,10 +144,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:
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/JspUtil.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/JspUtil.java 2010-07-07
20:38:35 UTC (rev 1501)
+++
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/JspUtil.java 2010-07-07
20:47:49 UTC (rev 1502)
@@ -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:
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Node.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Node.java 2010-07-07
20:38:35 UTC (rev 1501)
+++
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/Node.java 2010-07-07
20:47:49 UTC (rev 1502)
@@ -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();
+ }
+
+ }
}
/**
@@ -1908,6 +1926,9 @@
* (this probably could go elsewhere, but it's convenient here)
*/
public String getTemporaryVariableName() {
+ if (temporaryVariableName == null) {
+ temporaryVariableName = getRoot().nextTemporaryVariableName();
+ }
return temporaryVariableName;
}
Modified:
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/TagPluginManager.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/TagPluginManager.java 2010-07-07
20:38:35 UTC (rev 1501)
+++
branches/JBOSSWEB_2_0_0_GA_CP11_JBPAPP-4574/src/share/classes/org/apache/jasper/compiler/TagPluginManager.java 2010-07-07
20:47:49 UTC (rev 1502)
@@ -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 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 void setPluginAttribute(String key, Object value) {
+ pluginAttributes.put(key, value);
+ }
- public Object getPluginAttribute(String key) {
- return pluginAttributes.get(key);
- }
+ public Object getPluginAttribute(String key) {
+ return pluginAttributes.get(key);
+ }
- public boolean isScriptless() {
- return node.getChildInfo().isScriptless();
- }
+ 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 boolean isConstantAttribute(String attribute) {
+ Node.JspAttribute attr = getNodeAttribute(attribute);
+ if (attr == null)
+ return false;
+ return attr.isLiteral();
+ }
- public String getConstantAttribute(String attribute) {
- Node.JspAttribute attr = getNodeAttribute(attribute);
+ public String getConstantAttribute(String attribute) {
+ Node.JspAttribute attr = getNodeAttribute(attribute);
if (attr == null)
- return null;
- return attr.getValue();
- }
+ return null;
+ return attr.getValue();
+ }
- public boolean isAttributeSpecified(String attribute) {
- return getNodeAttribute(attribute) != null;
- }
+ public boolean isAttributeSpecified(String attribute) {
+ return getNodeAttribute(attribute) != null;
+ }
- public String getTemporaryVariableName() {
- return JspUtil.nextTemporaryVariableName();
- }
+ public String getTemporaryVariableName() {
+ return node.getRoot().nextTemporaryVariableName();
+ }
- public void generateImport(String imp) {
- pageInfo.addImport(imp);
- }
+ 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 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 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 generateAttribute(String attributeName) {
+ curNodes.add(new Node.AttributeGenerator(node.getStart(),
+ attributeName,
+ node));
+ }
- public void dontUseTagPlugin() {
- node.setUseTagPlugin(false);
- }
+ 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();
- }
+ 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;
- }
+ 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;
+ }
}
}