cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r535303 - /incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
Date Fri, 04 May 2007 15:58:47 GMT
Author: dkulp
Date: Fri May  4 08:58:46 2007
New Revision: 535303

URL: http://svn.apache.org/viewvc?view=rev&rev=535303
Log:
Fix thread safety issue in ResourceManager lists

Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java?view=diff&rev=535303&r1=535302&r2=535303
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/DefaultResourceManager.java
Fri May  4 08:58:46 2007
@@ -20,10 +20,9 @@
 package org.apache.cxf.resource;
 
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -33,7 +32,8 @@
     
     private static final Logger LOG = LogUtils.getL7dLogger(DefaultResourceManager.class);
 
-    protected final List<ResourceResolver> registeredResolvers = new LinkedList<ResourceResolver>();
+    protected final List<ResourceResolver> registeredResolvers 
+        = new CopyOnWriteArrayList<ResourceResolver>();
 
     public DefaultResourceManager() { 
         initializeDefaultResolvers(); 
@@ -44,9 +44,7 @@
     }
     
     public DefaultResourceManager(List<ResourceResolver> resolvers) {
-        for (Iterator<ResourceResolver> it = resolvers.iterator(); it.hasNext();) {
-            addResourceResolver(it.next());
-        }
+        registeredResolvers.addAll(resolvers);
     }
  
     public final <T> T resolveResource(String name, Class<T> type) { 
@@ -77,9 +75,7 @@
 
 
     public final List<ResourceResolver> getResourceResolvers() {
-        List<ResourceResolver> ret = new ArrayList<ResourceResolver>();
-        ret.addAll(registeredResolvers);
-        return ret; 
+        return Collections.unmodifiableList(registeredResolvers); 
     }
 
     



Mime
View raw message