Author: markt Date: Wed Jul 4 21:10:48 2012 New Revision: 1357410 URL: http://svn.apache.org/viewvc?rev=1357410&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53498 Fix atomicity bugs in use of concurrent collections. Based on a patch by Yu Lin.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1357407 Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java?rev=1357410&r1=1357409&r2=1357410&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java Wed Jul 4 21:10:48 2012 @@ -169,7 +169,7 @@ public class ApplicationContext /** * The merged context initialization parameters for this Context. */ - private Map<String,String> parameters = + private final ConcurrentHashMap<String,String> parameters = new ConcurrentHashMap<String,String>(); @@ -753,17 +753,14 @@ public class ApplicationContext public void removeAttribute(String name) { Object value = null; - boolean found = false; // Remove the specified attribute // Check for read only attribute - if (readOnlyAttributes.containsKey(name)) + if (readOnlyAttributes.containsKey(name)){ return; - found = attributes.containsKey(name); - if (found) { - value = attributes.get(name); - attributes.remove(name); - } else { + } + value = attributes.remove(name); + if (value == null) { return; } @@ -1260,12 +1257,7 @@ public class ApplicationContext @Override public boolean setInitParameter(String name, String value) { - if (parameters.containsKey(name)) { - return false; - } - - parameters.put(name, value); - return true; + return parameters.putIfAbsent(name, value) == null; } Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java?rev=1357410&r1=1357409&r2=1357410&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java Wed Jul 4 21:10:48 2012 @@ -168,10 +168,12 @@ public class ReplicatedContext extends S @Override public Object getAttribute(String name) { - if (tomcatAttributes.containsKey(name) ) - return tomcatAttributes.get(name); - else + Object obj = tomcatAttributes.get(name); + if (obj == null) { return super.getAttribute(name); + } else { + return obj; + } } @SuppressWarnings("unchecked") 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=1357410&r1=1357409&r2=1357410&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed Jul 4 21:10:48 2012 @@ -62,6 +62,10 @@ <code>file-size-threshold</code> option in web.xml) when request processing completes. (kkolinko) </fix> + <fix> + <bug>53498</bug>: Fix atomicity bugs in use of concurrent collections. + Based on a patch by Yu Lin. (markt) + </fix> </changelog> </subsection> <subsection name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org