You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ie...@apache.org on 2010/01/21 16:44:55 UTC

svn commit: r901746 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java

Author: ieb
Date: Thu Jan 21 15:44:55 2010
New Revision: 901746

URL: http://svn.apache.org/viewvc?rev=901746&view=rev
Log:
SLING-1290 Fiexed by protecting the fast fail iterator by taking a copy on update of the collection. see Jira for more info.

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java?rev=901746&r1=901745&r2=901746&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntry.java Thu Jan 21 15:44:55 2010
@@ -81,6 +81,8 @@
 
     private FastTreeMap storageMap = new FastTreeMap();
 
+    private Collection<ResourceProviderEntry> storageMapValues = new ArrayList<ResourceProviderEntry>();
+
     /**
      * Creates an instance of this class with the given path relative to the
      * parent resource provider entry, encapsulating the given ResourceProvider,
@@ -112,6 +114,7 @@
 
         // this will consume slightly more memory but ensures read is fast.
         storageMap.setFast(true);
+        
     }
 
     /**
@@ -281,8 +284,11 @@
 
 
     //------------------ Map methods, here so that we can delegate 2 maps together
+    @SuppressWarnings("unchecked")
     public void put(String key, ResourceProviderEntry value) {
         storageMap.put(key,value);
+        // get a thread safe copy, the ArrayList constructor does a toArray which is thread safe.
+        storageMapValues = new ArrayList<ResourceProviderEntry>(storageMap.values());
     }
 
     public boolean containsKey(String key) {
@@ -293,9 +299,8 @@
         return (ResourceProviderEntry) storageMap.get(key);
     }
 
-    @SuppressWarnings("unchecked")
     public Collection<ResourceProviderEntry> values() {
-        return storageMap.values();
+        return storageMapValues;
     }
 
     public boolean removeResourceProvider(String prefix,