cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amic...@apache.org
Subject svn commit: r1539982 - /cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
Date Fri, 08 Nov 2013 11:16:23 GMT
Author: amichai
Date: Fri Nov  8 11:16:23 2013
New Revision: 1539982

URL: http://svn.apache.org/r1539982
Log:
Fix PublishingEndpointListenerFactory service leak (never being unregistered)

Modified:
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java

Modified: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java?rev=1539982&r1=1539981&r2=1539982&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
(original)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
Fri Nov  8 11:16:23 2013
@@ -46,6 +46,7 @@ public class PublishingEndpointListenerF
     private final BundleContext bctx;
     private final ZooKeeper zk;
     private final List<PublishingEndpointListener> listeners = new ArrayList<PublishingEndpointListener>();
+    private ServiceRegistration serviceRegistration;
 
     public PublishingEndpointListenerFactory(ZooKeeper zk, BundleContext bctx) {
         this.bctx = bctx;
@@ -55,18 +56,18 @@ public class PublishingEndpointListenerF
     public PublishingEndpointListener getService(Bundle b, ServiceRegistration<PublishingEndpointListener>
sr) {
         LOG.debug("new EndpointListener from factory");
         synchronized (listeners) {
-            PublishingEndpointListener epl = new PublishingEndpointListener(zk, bctx);
-            listeners.add(epl);
-            return epl;
+            PublishingEndpointListener pel = new PublishingEndpointListener(zk, bctx);
+            listeners.add(pel);
+            return pel;
         }
     }
 
     public void ungetService(Bundle b, ServiceRegistration<PublishingEndpointListener>
sr, 
-                             PublishingEndpointListener service) {
+                             PublishingEndpointListener pel) {
         LOG.debug("remove EndpointListener");
         synchronized (listeners) {
-            if (listeners.remove(service)) {
-                ((PublishingEndpointListener)service).close();
+            if (listeners.remove(pel)) {
+                pel.close();
             }
         }
     }
@@ -77,13 +78,17 @@ public class PublishingEndpointListenerF
                   "(&(" + Constants.OBJECTCLASS + "=*)(" + RemoteConstants.ENDPOINT_FRAMEWORK_UUID
                   + "=" + Utils.getUUID(bctx) + "))");
         props.put(ZooKeeperDiscovery.DISCOVERY_ZOOKEEPER_ID, "true");
-        bctx.registerService(EndpointListener.class.getName(), this, props);
+        serviceRegistration = bctx.registerService(EndpointListener.class.getName(), this,
props);
     }
 
     public synchronized void stop() {
+        if (serviceRegistration != null) {
+            serviceRegistration.unregister();
+            serviceRegistration = null;
+        }
         synchronized (listeners) {
-            for (PublishingEndpointListener epl : listeners) {
-                epl.close();
+            for (PublishingEndpointListener pel : listeners) {
+                pel.close();
             }
             listeners.clear();
         }



Mime
View raw message