geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r926532 - /geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
Date Tue, 23 Mar 2010 12:09:43 GMT
Author: kevan
Date: Tue Mar 23 12:09:43 2010
New Revision: 926532

URL: http://svn.apache.org/viewvc?rev=926532&view=rev
Log:
GERONIMO-5200 Fix potential problems caused by concurrent access to HashSet from multiple
Threads

Modified:
    geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java?rev=926532&r1=926531&r2=926532&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
Tue Mar 23 12:09:43 2010
@@ -31,6 +31,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -61,7 +62,7 @@ public class MultiParentClassLoader exte
     private final String[] hiddenResources;
     private final String[] nonOverridableResources;
     private boolean destroyed = false;
-    private Set<String> resourcesNotFound = new HashSet<String>();
+    private Map<String,Object> resourcesNotFound = new ConcurrentHashMap<String,Object>();
 
     // I used this pattern as its temporary and with the static final we get compile time

     // optimizations.
@@ -552,7 +553,7 @@ public class MultiParentClassLoader exte
     }
 
     public URL getResource(String name) {
-        if (isDestroyed() || resourcesNotFound.contains(name)) {
+        if (isDestroyed() || resourcesNotFound.containsKey(name)) {
             return null;
         }
 
@@ -594,12 +595,9 @@ public class MultiParentClassLoader exte
 
         // 
         // Resource not found -- no need to search for it again
+        // Use the name as key and value. We don't care about the value and it needs to be
non-null.
         // 
-        if (!resourcesNotFound.contains(name)) {
-            synchronized(resourcesNotFound) {
-                resourcesNotFound.add(name);
-            }
-        }
+        resourcesNotFound.put(name, name);
 
         return null;
     }



Mime
View raw message