ASF Bugzilla – Attachment 22483 Details for
Bug 45691
Jasper creates duplicate variable names
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to be applied to the package org.apache.jasper.compiler
duplicateVariableNames.diff (text/plain), 3.91 KB, created by
Stefan Birkner
on 2008-08-26 07:49:41 UTC
(
hide
)
Description:
Patch to be applied to the package org.apache.jasper.compiler
Filename:
MIME Type:
Creator:
Stefan Birkner
Created:
2008-08-26 07:49:41 UTC
Size:
3.91 KB
patch
obsolete
>Index: Generator.java >=================================================================== >--- Generator.java (revision 688768) >+++ Generator.java (working copy) >@@ -43,6 +43,7 @@ > import org.apache.jasper.Constants; > import org.apache.jasper.JasperException; > import org.apache.jasper.JspCompilationContext; >+import org.apache.jasper.compiler.Node.NamedAttribute; > import org.apache.jasper.runtime.JspRuntimeLibrary; > import org.xml.sax.Attributes; > >@@ -102,6 +103,11 @@ > > private GenBuffer charArrayBuffer; > >+ private HashMap<NamedAttribute, String> variableNamesOfNamedAttributes; >+ >+ /** The {@code variableNameCounter} is used to generate different variable names for named attributes. */ >+ private int variableNameCounter; >+ > /** > * @param s > * the input string >@@ -819,7 +825,7 @@ > } > return v; > } else if (attr.isNamedAttribute()) { >- return attr.getNamedAttributeNode().getTemporaryVariableName(); >+ return getVariableName(attr.getNamedAttributeNode()); > } else { > if (encode) { > return "org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode(" >@@ -3128,7 +3134,7 @@ > public String generateNamedAttributeValue(Node.NamedAttribute n) > throws JasperException { > >- String varName = n.getTemporaryVariableName(); >+ String varName = getVariableName(n); > > // If the only body element for this named attribute node is > // template text, we need not generate an extra call to >@@ -3183,7 +3189,7 @@ > */ > public String generateNamedAttributeJspFragment(Node.NamedAttribute n, > String tagHandlerVar) throws JasperException { >- String varName = n.getTemporaryVariableName(); >+ String varName = getVariableName(n); > > out.printin("javax.servlet.jsp.tagext.JspFragment " + varName > + " = "); >@@ -3324,6 +3330,9 @@ > if (isPoolingEnabled) { > tagHandlerPoolNames = new Vector(); > } >+ >+ variableNamesOfNamedAttributes = new HashMap<NamedAttribute, String>(); >+ variableNameCounter = 0; > } > > /** >@@ -3764,6 +3773,19 @@ > } > > /* >+ * Returns the variable name of a named attribute. >+ */ >+ private String getVariableName(NamedAttribute attribute) { >+ String name = variableNamesOfNamedAttributes.get(attribute); >+ if (name == null) { >+ name = Constants.TEMP_VARIABLE_NAME_PREFIX + (variableNameCounter++); >+ variableNamesOfNamedAttributes.put(attribute, name); >+ } >+ >+ return name; >+ } >+ >+ /* > * Generates the getter method for the given attribute name. > */ > private String toGetterMethod(String attrName) { >Index: Node.java >=================================================================== >--- Node.java (revision 688768) >+++ Node.java (working copy) >@@ -1842,9 +1842,6 @@ > */ > public static class NamedAttribute extends Node { > >- // A unique temporary variable name suitable for code generation >- private String temporaryVariableName; >- > // True if this node is to be trimmed, or false otherwise > private boolean trim = true; > >@@ -1907,17 +1904,6 @@ > return trim; > } > >- /** >- * @return A unique temporary variable name to store the result in. >- * (this probably could go elsewhere, but it's convenient here) >- */ >- public String getTemporaryVariableName() { >- if (temporaryVariableName == null) { >- temporaryVariableName = JspUtil.nextTemporaryVariableName(); >- } >- return temporaryVariableName; >- } >- > /* > * Get the attribute value from this named attribute (<jsp:attribute>). > * Since this method is only for attributes that are not rtexpr, we can
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 45691
:
22482
| 22483