Author: markt
Date: Thu May 26 12:48:24 2016
New Revision: 1745599
URL: http://svn.apache.org/viewvc?rev=1745599&view=rev
Log:
Make resourceEntries a ConcurrentHashMap else there is a risk of a threading
issues when different threads read and write at the same time.
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java?rev=1745599&r1=1745598&r2=1745599&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoaderBase.java
Thu May 26 12:48:24 2016
@@ -56,6 +56,7 @@ import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.jar.Attributes;
@@ -335,7 +336,7 @@ public abstract class WebappClassLoaderB
* The cache of ResourceEntry for classes and resources we have loaded,
* keyed by resource name.
*/
- protected HashMap<String, ResourceEntry> resourceEntries = new
HashMap<String, ResourceEntry>();
+ protected Map<String, ResourceEntry> resourceEntries = new
ConcurrentHashMap<String, ResourceEntry>();
/**
@@ -2301,9 +2302,8 @@ public abstract class WebappClassLoaderB
private final void clearReferencesStaticFinal() {
- @SuppressWarnings("unchecked") // resourceEntries is HashMap<String,
ResourceEntry>
- Collection<ResourceEntry> values =
- ((HashMap<String,ResourceEntry>) resourceEntries.clone()).values();
+ List<ResourceEntry> values = new ArrayList<ResourceEntry>();
+ values.addAll(resourceEntries.values());
Iterator<ResourceEntry> loadedClasses = values.iterator();
//
// walk through all loaded class to trigger initialization for
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=1745599&r1=1745598&r2=1745599&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu May 26 12:48:24 2016
@@ -109,6 +109,10 @@
leaks is made. Log a warning if running on Java 9 with this check
enabled but without the command line option it requires. (markt)
</fix>
+ <fix>
+ Fix potential concurrency issue with web application class loader with
+ concurrent reads and writes of the resource cache. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]