sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1573296 - in /sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl: cluster/ClusterTest.java setup/Instance.java
Date Sun, 02 Mar 2014 13:03:17 GMT
Author: stefanegli
Date: Sun Mar  2 13:03:17 2014
New Revision: 1573296

URL: http://svn.apache.org/r1573296
Log:
no-jira : properly removing event listener in Instance.stop() to reduce log noise

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterTest.java
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterTest.java?rev=1573296&r1=1573295&r2=1573296&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterTest.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/cluster/ClusterTest.java
Sun Mar  2 13:03:17 2014
@@ -197,8 +197,8 @@ public class ClusterTest {
         instance1.dumpRepo();
         String actualClusterId = instance1.getClusterViewService()
                 .getClusterView().getId();
-        System.err.println("expected cluster id: "+newClusterId1);
-        System.err.println("actual   cluster id: "+actualClusterId);
+        logger.info("expected cluster id: "+newClusterId1);
+        logger.info("actual   cluster id: "+actualClusterId);
 		assertEquals(newClusterId1, actualClusterId);
     }
     

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java?rev=1573296&r1=1573295&r2=1573296&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/Instance.java
Sun Mar  2 13:03:17 2014
@@ -202,6 +202,10 @@ public class Instance {
     private Server jettyServer;
 
     private MyConfig config;
+
+    private EventListener observationListener;
+    
+    private ObservationManager observationManager;
     
     private class HeartbeatRunner implements Runnable {
     	
@@ -291,10 +295,10 @@ public class Instance {
         resourceResolver = resourceResolverFactory
                 .getAdministrativeResourceResolver(null);
         Session session = resourceResolver.adaptTo(Session.class);
-        ObservationManager observationManager = session.getWorkspace()
+        observationManager = session.getWorkspace()
                 .getObservationManager();
 
-        observationManager.addEventListener(
+        observationListener =
                 new EventListener() {
 
                     public void onEvent(EventIterator events) {
@@ -331,7 +335,10 @@ public class Instance {
                                     "Throwable occurred in onEvent: " + th, th);
                         }
                     }
-                }, Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED
+        };
+        observationManager.addEventListener(
+                observationListener
+                , Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED
                         | Event.PROPERTY_CHANGED | Event.PROPERTY_ADDED
                         | Event.PROPERTY_REMOVED | Event.PERSIST, "/", true,
                 null,
@@ -571,6 +578,10 @@ public class Instance {
     		heartbeatRunner.stop();
     		heartbeatRunner = null;
     	}
+    	if ((observationListener != null) && (observationManager != null)) {
+            observationManager.removeEventListener(observationListener);
+    	}
+    	
         if (resourceResolver != null) {
             resourceResolver.close();
         }



Mime
View raw message