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/05/29 15:41:32 UTC

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

Author: amichai
Date: Wed May 29 13:41:31 2013
New Revision: 1487482

URL: http://svn.apache.org/r1487482
Log:
DOSGI-177 Fix stopped services still appear to be available and memory leak

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=1487482&r1=1487481&r2=1487482&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 Wed May 29 13:41:31 2013
@@ -164,8 +164,11 @@ public class TopologyManagerImport imple
                 ips = new ArrayList<EndpointDescription>();
                 importPossibilities.put(filter, ips);
             }
-
-            ips.add(epd);
+            // prevent adding the same endpoint multiple times, which can happen sometimes,
+            // and which causes imports to remain available even when services are actually down
+            if (!ips.contains(epd)) {
+                ips.add(epd);
+            }
         }
     }
 
@@ -214,7 +217,7 @@ public class TopologyManagerImport imple
     
     private void unexportNotAvailableServices(String filter) {
         List<ImportRegistration> importRegistrations = getImportedServices(filter);
-        if (importRegistrations.size() == 0) {
+        if (importRegistrations.isEmpty()) {
             return;
         }
             
@@ -228,6 +231,10 @@ public class TopologyManagerImport imple
                 it.remove();
             }
         }
+
+        if (importRegistrations.isEmpty()) {
+            importedServices.remove(filter);
+        }
     }
     
     private boolean isImportPossibilityAvailable(EndpointDescription ep, String filter) {