Author: markt Date: Sun Aug 31 06:47:57 2008 New Revision: 690693 URL: http://svn.apache.org/viewvc?rev=690693&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45691 Make temporary variable name generation safe when multiple compilations are running in parallel
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java tomcat/trunk/java/org/apache/jasper/compiler/Node.java tomcat/trunk/java/org/apache/jasper/compiler/TagPluginManager.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=690693&r1=690692&r2=690693&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Sun Aug 31 06:47:57 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/trunk/java/org/apache/jasper/compiler/JspUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java?rev=690693&r1=690692&r2=690693&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java Sun Aug 31 06:47:57 2008 @@ -55,8 +55,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(); @@ -599,22 +597,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: tomcat/trunk/java/org/apache/jasper/compiler/Node.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Node.java?rev=690693&r1=690692&r2=690693&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Node.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Node.java Sun Aug 31 06:47:57 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/trunk/java/org/apache/jasper/compiler/TagPluginManager.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TagPluginManager.java?rev=690693&r1=690692&r2=690693&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/TagPluginManager.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/TagPluginManager.java Sun Aug 31 06:47:57 2008 @@ -191,7 +191,7 @@ } public String getTemporaryVariableName() { - return JspUtil.nextTemporaryVariableName(); + return node.getRoot().nextTemporaryVariableName(); } public void generateImport(String imp) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]