aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1690235 - /aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
Date Fri, 10 Jul 2015 09:56:55 GMT
Author: gnodet
Date: Fri Jul 10 09:56:54 2015
New Revision: 1690235

URL: http://svn.apache.org/r1690235
Log:
[ARIES-1350] Namespace handler can't be found even if it's registered correctly

Modified:
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java?rev=1690235&r1=1690234&r2=1690235&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/namespace/NamespaceHandlerRegistryImpl.java
Fri Jul 10 09:56:54 2015
@@ -98,9 +98,9 @@ public class NamespaceHandlerRegistryImp
     private final SchemaFactory schemaFactory =
                         SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 
-    // Access to this variable is not synchronized.  The list itself is concurrent
-    private final CopyOnWriteArrayList<NamespaceHandlerSetImpl> sets =
-                        new CopyOnWriteArrayList<NamespaceHandlerSetImpl>();
+    // Access to this variable is must be synchronized on itself
+    private final ArrayList<NamespaceHandlerSetImpl> sets =
+                        new ArrayList<NamespaceHandlerSetImpl>();
 
     public NamespaceHandlerRegistryImpl(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
@@ -155,6 +155,10 @@ public class NamespaceHandlerRegistryImp
                 h = handlers.get(uri);
             }
             if (h.add(handler)) {
+                List<NamespaceHandlerSetImpl> sets;
+                synchronized (this.sets) {
+                    sets = new ArrayList<NamespaceHandlerSetImpl>(this.sets);
+                }
                 for (NamespaceHandlerSetImpl s : sets) {
                     s.registerHandler(uri, handler);
                 }
@@ -169,6 +173,10 @@ public class NamespaceHandlerRegistryImp
             if (!h.remove(handler)) {
                 continue;
             }
+            List<NamespaceHandlerSetImpl> sets;
+            synchronized (this.sets) {
+                sets = new ArrayList<NamespaceHandlerSetImpl>(this.sets);
+            }
             for (NamespaceHandlerSetImpl s : sets) {
                 s.unregisterHandler(uri, handler);
             }
@@ -226,8 +234,11 @@ public class NamespaceHandlerRegistryImp
     }
     
     public NamespaceHandlerSet getNamespaceHandlers(Set<URI> uris, Bundle bundle) {
-        NamespaceHandlerSetImpl s = new NamespaceHandlerSetImpl(uris, bundle);
-        sets.add(s);
+        NamespaceHandlerSetImpl s;
+        synchronized (sets) {
+            s = new NamespaceHandlerSetImpl(uris, bundle);
+            sets.add(s);
+        }
         return s;
     }
 
@@ -557,7 +568,9 @@ public class NamespaceHandlerRegistryImp
         }
 
         public void destroy() {
-            NamespaceHandlerRegistryImpl.this.sets.remove(this);
+            synchronized (NamespaceHandlerRegistryImpl.this.sets) {
+                NamespaceHandlerRegistryImpl.this.sets.remove(this);
+            }
         }
 
         public void registerHandler(URI uri, NamespaceHandler handler) {



Mime
View raw message