Author: markt Date: Mon Jul 29 21:03:22 2013 New Revision: 1508200 URL: http://svn.apache.org/r1508200 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55309 Fix concurrency issue in TagPluginManager PageInfo should not be a field as it is per page and there will be conflicts with concurrent compilations. Patch provided by Sheldon Shao.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1508196 Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java?rev=1508200&r1=1508199&r2=1508200&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/TagPluginManager.java Mon Jul 29 21:03:22 2013 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -45,7 +45,6 @@ public class TagPluginManager { private boolean initialized = false; private HashMap<String, TagPlugin> tagPlugins = null; private ServletContext ctxt; - private PageInfo pageInfo; public TagPluginManager(ServletContext ctxt) { this.ctxt = ctxt; @@ -59,19 +58,9 @@ public class TagPluginManager { return; } - this.pageInfo = pageInfo; - - page.visit(new Node.Visitor() { - @Override - public void visit(Node.CustomTag n) - throws JasperException { - invokePlugin(n); - visitBody(n); - } - }); - + page.visit(new NodeVisitor(this, pageInfo)); } - + private void init(ErrorDispatcher err) throws JasperException { if (initialized) return; @@ -175,12 +164,12 @@ public class TagPluginManager { } /** - * Invoke tag plugin for the given custom tag, if a plugin exists for + * Invoke tag plugin for the given custom tag, if a plugin exists for * the custom tag's tag handler. * * The given custom tag node will be manipulated by the plugin. */ - private void invokePlugin(Node.CustomTag n) { + private void invokePlugin(Node.CustomTag n, PageInfo pageInfo) { TagPlugin tagPlugin = tagPlugins.get(n.getTagHandlerClass().getName()); if (tagPlugin == null) { return; @@ -191,8 +180,24 @@ public class TagPluginManager { tagPlugin.doTag(tagPluginContext); } - static class TagPluginContextImpl implements TagPluginContext { - private Node.CustomTag node; + private static class NodeVisitor extends Node.Visitor { + private TagPluginManager manager; + private PageInfo pageInfo; + + public NodeVisitor(TagPluginManager manager, PageInfo pageInfo) { + this.manager = manager; + this.pageInfo = pageInfo; + } + + @Override + public void visit(Node.CustomTag n) throws JasperException { + manager.invokePlugin(n, pageInfo); + visitBody(n); + } + } + + private static class TagPluginContextImpl implements TagPluginContext { + private final Node.CustomTag node; private Node.Nodes curNodes; private PageInfo pageInfo; private HashMap<String, Object> pluginAttributes; @@ -291,7 +296,7 @@ public class TagPluginManager { @Override public void generateBody() { - // Since we'll generate the body anyway, this is really a nop, + // 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(); Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1508200&r1=1508199&r2=1508200&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Jul 29 21:03:22 2013 @@ -152,6 +152,10 @@ will return a result when the property cannot be coerced into an integer. (violetagg) </fix> + <fix> + <bug>55309</bug>: Fix concurrency issue with JSP compilation and the + tag plug-in manager. Patch provided by Sheldon Shao. (markt) + </fix> </changelog> </subsection> <subsection name="Cluster"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org