You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by am...@apache.org on 2013/07/07 11:05:17 UTC

svn commit: r1500389 - /cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java

Author: amichai
Date: Sun Jul  7 09:05:17 2013
New Revision: 1500389

URL: http://svn.apache.org/r1500389
Log:
Fix another ConcurrentModificationException when removing imported service

Modified:
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java?rev=1500389&r1=1500388&r2=1500389&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/importer/TopologyManagerImport.java Sun Jul  7 09:05:17 2013
@@ -312,13 +312,18 @@ public class TopologyManagerImport imple
      * @param ref the import reference to remove
      */
     private void removeImport(ImportRegistration reg, ImportReference ref) {
+        // this method may be called recursively by calling ImportRegistration.close()
+        // and receiving a RemoteServiceAdminEvent for its unregistration, which results
+        // in a ConcurrentModificationException. We avoid this by closing the registrations
+        // only after data structure manipulation is done, and being re-entrant.
         synchronized (importedServices) {
+            List<ImportRegistration> removed = new ArrayList<ImportRegistration>();
             for (Iterator<List<ImportRegistration>> it1 = importedServices.values().iterator(); it1.hasNext();) {
                 Collection<ImportRegistration> irs = it1.next();
                 for (Iterator<ImportRegistration> it2 = irs.iterator(); it2.hasNext();) {
                     ImportRegistration ir = it2.next();
                     if (ir.equals(reg) || ir.getImportReference().equals(ref)) {
-                        ir.close();
+                        removed.add(ir);
                         it2.remove();
                     }
                 }
@@ -326,6 +331,9 @@ public class TopologyManagerImport imple
                     it1.remove();
                 }
             }
+            for (ImportRegistration ir : removed) {
+                ir.close();
+            }
         }
     }