jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1503670 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/MixinTest.java
Date Tue, 16 Jul 2013 11:56:22 GMT
Author: mduerig
Date: Tue Jul 16 11:56:22 2013
New Revision: 1503670

URL: http://svn.apache.org/r1503670
Log:
JCR-3621: Race condition in MixinTest between event delivery and unregistering the observation
listener
Move observation listener deregistration to a finally block

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/MixinTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/MixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/MixinTest.java?rev=1503670&r1=1503669&r2=1503670&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/MixinTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/MixinTest.java
Tue Jul 16 11:56:22 2013
@@ -40,16 +40,18 @@ public class MixinTest extends AbstractO
 
         EventResult propertyAddedListener = new EventResult(log);
         addEventListener(propertyAddedListener, new String[]{mixReferenceable}, Event.PROPERTY_ADDED);
-
-        testRootNode.getNode(nodeName1).setProperty(propertyName1, "test");
-        testRootNode.getNode(nodeName2).setProperty(propertyName1, "test");
-        testRootNode.getNode(nodeName3).setProperty(propertyName1, "test");
-        testRootNode.save();
-
-        removeEventListener(propertyAddedListener);
-        Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
-        checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1,
-                                               nodeName3 + "/" + propertyName1});
+        try {
+            testRootNode.getNode(nodeName1).setProperty(propertyName1, "test");
+            testRootNode.getNode(nodeName2).setProperty(propertyName1, "test");
+            testRootNode.getNode(nodeName3).setProperty(propertyName1, "test");
+            testRootNode.save();
+
+            Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
+            checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1,
+                                                   nodeName3 + "/" + propertyName1});
+        } finally {
+            removeEventListener(propertyAddedListener);
+        }
     }
 
     /**
@@ -63,17 +65,19 @@ public class MixinTest extends AbstractO
 
         EventResult propertyAddedListener = new EventResult(log);
         addEventListener(propertyAddedListener, new String[]{mixReferenceable, mixLockable},
Event.PROPERTY_ADDED);
-
-        testRootNode.getNode(nodeName1).setProperty(propertyName1, "test");
-        testRootNode.getNode(nodeName2).setProperty(propertyName1, "test");
-        testRootNode.getNode(nodeName3).setProperty(propertyName1, "test");
-        testRootNode.save();
-
-        removeEventListener(propertyAddedListener);
-        Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
-        checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1,
-                                               nodeName2 + "/" + propertyName1,
-                                               nodeName3 + "/" + propertyName1});
+        try {
+            testRootNode.getNode(nodeName1).setProperty(propertyName1, "test");
+            testRootNode.getNode(nodeName2).setProperty(propertyName1, "test");
+            testRootNode.getNode(nodeName3).setProperty(propertyName1, "test");
+            testRootNode.save();
+
+            Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
+            checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1,
+                                                   nodeName2 + "/" + propertyName1,
+                                                   nodeName3 + "/" + propertyName1});
+        } finally {
+            removeEventListener(propertyAddedListener);
+        }
     }
 
     /**
@@ -91,16 +95,18 @@ public class MixinTest extends AbstractO
 
         EventResult propertyAddedListener = new EventResult(log);
         addEventListener(propertyAddedListener, new String[]{mixReferenceable}, Event.PROPERTY_ADDED);
-
-        node1.setProperty(propertyName1, "test");
-        node2.setProperty(propertyName1, "test");
-        node3.setProperty(propertyName1, "test");
-        testRootNode.save();
-
-        removeEventListener(propertyAddedListener);
-        Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
-        checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1,
-                                               nodeName3 + "/" + propertyName1});
+        try {
+            node1.setProperty(propertyName1, "test");
+            node2.setProperty(propertyName1, "test");
+            node3.setProperty(propertyName1, "test");
+            testRootNode.save();
+
+            Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
+            checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1,
+                                                   nodeName3 + "/" + propertyName1});
+        } finally {
+            removeEventListener(propertyAddedListener);
+        }
     }
 
     /**
@@ -117,13 +123,15 @@ public class MixinTest extends AbstractO
         EventResult propertyAddedListener = new EventResult(log);
         // mix:versionable is derived from mix:referenceable
         addEventListener(propertyAddedListener, new String[]{mixReferenceable}, Event.PROPERTY_ADDED);
-
-        node1.setProperty(propertyName1, "test");
-        testRootNode.save();
-
-        removeEventListener(propertyAddedListener);
-        Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
-        checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1});
+        try {
+            node1.setProperty(propertyName1, "test");
+            testRootNode.save();
+
+            Event[] added = propertyAddedListener.getEvents(DEFAULT_WAIT_TIMEOUT);
+            checkPropertyAdded(added, new String[]{nodeName1 + "/" + propertyName1});
+        } finally {
+            removeEventListener(propertyAddedListener);
+        }
     }
 
     /**



Mime
View raw message