From b876aa9f3495a9b4816fc1187ae058e50f1285df Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 8 Jun 2011 15:52:26 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51340 Fix thread-safety issue when parsing multiple web.xml files in parallel. Apache Tomcat does not do this but products that embed it may. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1133446 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/startup/ContextConfig.java | 13 +++++++------ webapps/docs/changelog.xml | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java index adecb5f49..ac396c981 100644 --- a/java/org/apache/catalina/startup/ContextConfig.java +++ b/java/org/apache/catalina/startup/ContextConfig.java @@ -1676,13 +1676,18 @@ public class ContextConfig // thread safe. Whilst there should only be one thread at a time // processing a config, play safe and sync. Digester digester; + WebRuleSet ruleSet; if (fragment) { digester = webFragmentDigester; + ruleSet = webFragmentRuleSet; } else { digester = webDigester; + ruleSet = webRuleSet; } - synchronized(digester) { + // Sync on the ruleSet since the same ruleSet is shared across all four + // digesters + synchronized(ruleSet) { digester.push(dest); digester.setErrorHandler(handler); @@ -1713,11 +1718,7 @@ public class ContextConfig ok = false; } finally { digester.reset(); - if (fragment) { - webFragmentRuleSet.recycle(); - } else { - webRuleSet.recycle(); - } + ruleSet.recycle(); } } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 34374e6a6..b42f0bced 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -71,6 +71,11 @@ Avoid possible NPE when logging requests received during embedded Tomcat shutdown. (markt) + + 51340: Fix thread-safety issue when parsing multiple web.xml + files in parallel. Apache Tomcat does not do this but products that + embed it may. (markt) + -- 2.11.0