Author: peter_firmstone
Date: Mon May 27 11:21:16 2013
New Revision: 1486580

URL: http://svn.apache.org/r1486580
Log:
River-420 Fixes for unsafe publication by exporting during construction.

Unsynchronized access to ArrayList reference broke two tests when it was 
replaced with a defensive copy.  Fix: call method at time list is required.

Modified:
    
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/RegisterForAvailabilityEventTest05.java
    
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TestEventListener05.java
    
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TransactionRegisterForAvailabilityEventTest05.java

Modified: 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/RegisterForAvailabilityEventTest05.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/RegisterForAvailabilityEventTest05.java?rev=1486580&r1=1486579&r2=1486580&view=diff
==============================================================================
--- 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/RegisterForAvailabilityEventTest05.java
 (original)
+++ 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/RegisterForAvailabilityEventTest05.java
 Mon May 27 11:21:16 2013
@@ -40,12 +40,12 @@ import com.sun.jini.qa.harness.TestExcep
  */
 public class RegisterForAvailabilityEventTest05 extends JavaSpaceTest {
 
-    private ArrayList templates = new ArrayList();
-    private ArrayList expectedResult = new ArrayList();
+    private final ArrayList templates = new ArrayList();
+    private final ArrayList expectedResult = new ArrayList();
 
-    private SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
-    private SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
-    private SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
+    private final SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 
1);
+    private final SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 
2);
+    private final SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 
2);
 
     /**
      * This method asserts that for JavaSpace05's
@@ -91,7 +91,7 @@ public class RegisterForAvailabilityEven
      *
      * @throws Exception
      */
-    public void run() throws Exception {
+    public synchronized void run() throws Exception {
         ArrayList registrations = new ArrayList();
 
         TestEventListener05.setConfiguration(getConfig().getConfiguration());
@@ -104,11 +104,10 @@ public class RegisterForAvailabilityEven
                 null, true, testEventListener0, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
         final long gotER0Timestamp = System.currentTimeMillis();
-        List notifications = testEventListener0.getNotifications();
         expectedResult.add(sampleEntry1);  // this entry is to trigger the 
event
         space.write(sampleEntry1, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener0.getNotifications(), 
expectedResult,
                            "Writing one entry to trigger an event");
         registrations.add(er0);
         reset();
@@ -119,13 +118,12 @@ public class RegisterForAvailabilityEven
         EventRegistration er1 = space05.registerForAvailabilityEvent(templates,
                 null, true, testEventListener1, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener1.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, null, leaseForeverTime);
         space.write(sampleEntry2, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener1.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events");
         registrations.add(er1);
         reset();
@@ -135,13 +133,12 @@ public class RegisterForAvailabilityEven
         EventRegistration er2 = space05.registerForAvailabilityEvent(templates,
                 null, true, testEventListener2, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener2.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, null, leaseForeverTime);
         space.write(sampleEntry3, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener2.getNotifications(), 
expectedResult,
                 "Writing 2 entries to trigger 2 events (with single 
template)");
         registrations.add(er2);
         reset();
@@ -151,7 +148,6 @@ public class RegisterForAvailabilityEven
         EventRegistration er3 = space05.registerForAvailabilityEvent(templates,
                 null, true, testEventListener3, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener3.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
@@ -159,7 +155,7 @@ public class RegisterForAvailabilityEven
         space.write(sampleEntry2, null, leaseForeverTime);
         space.write(sampleEntry3, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener3.getNotifications(), 
expectedResult,
                 "Writing 3 entries to trigger 3 events (with single 
template)");
         registrations.add(er3);
         reset();
@@ -169,13 +165,12 @@ public class RegisterForAvailabilityEven
         EventRegistration er4 = space05.registerForAvailabilityEvent(templates,
                 null, true, testEventListener4, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener4.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, null, leaseForeverTime);
         space.write(sampleEntry2, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener4.getNotifications(), 
expectedResult,
                 "Writing 2 entries to trigger 2 events (with null template)");
         registrations.add(er4);
         reset();
@@ -185,13 +180,12 @@ public class RegisterForAvailabilityEven
         EventRegistration er5 = space05.registerForAvailabilityEvent(templates,
                 null, true, testEventListener5, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener5.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry1);
         space.write(sampleEntry1, null, leaseForeverTime);
         space.write(sampleEntry1, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener5.getNotifications(), 
expectedResult,
                            "Writing 2 duplicate entries to trigger 2 events "
                            + "(with null template)");
 
@@ -211,13 +205,12 @@ public class RegisterForAvailabilityEven
         EventRegistration er6 = space05.registerForAvailabilityEvent(templates,
                 null, true, testEventListener6, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener6.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, null, leaseForeverTime);
         space.write(sampleEntry3, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener6.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events " +
                            "(with multiple matching templates)");
         registrations.add(er6);
@@ -234,11 +227,10 @@ public class RegisterForAvailabilityEven
                 templates, null, false,
                 testEventListener0a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener0a.getNotifications();
         expectedResult.add(sampleEntry1);  // this entry is to trigger the 
event
         space.write(sampleEntry1, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener0a.getNotifications(), 
expectedResult,
                            "Writing one entry to trigger an event");
         registrations.add(er0a);
         reset();
@@ -250,13 +242,12 @@ public class RegisterForAvailabilityEven
                 templates, null, false,
                 testEventListener1a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener1a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, null, leaseForeverTime);
         space.write(sampleEntry2, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener1a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events");
         registrations.add(er1a);
         reset();
@@ -267,13 +258,12 @@ public class RegisterForAvailabilityEven
                 templates, null, false,
                 testEventListener2a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener2a.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, null, leaseForeverTime);
         space.write(sampleEntry3, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener2a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events "
                            + "(with single template)");
         registrations.add(er2a);
@@ -285,7 +275,6 @@ public class RegisterForAvailabilityEven
                 templates, null, false,
                 testEventListener3a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener3a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
@@ -293,7 +282,7 @@ public class RegisterForAvailabilityEven
         space.write(sampleEntry2, null, leaseForeverTime);
         space.write(sampleEntry3, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener3a.getNotifications(), 
expectedResult,
                            "Writing 3 entries to trigger 3 events "
                            + "(with single template)");
         registrations.add(er3a);
@@ -305,13 +294,12 @@ public class RegisterForAvailabilityEven
                 templates, null, false,
                 testEventListener4a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener4a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, null, leaseForeverTime);
         space.write(sampleEntry2, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener4a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events "
                            + "(with null template)");
         registrations.add(er4a);
@@ -323,13 +311,12 @@ public class RegisterForAvailabilityEven
                 templates, null, false,
                 testEventListener5a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener5a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry1);
         space.write(sampleEntry1, null, leaseForeverTime);
         space.write(sampleEntry1, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener5a.getNotifications(), 
expectedResult,
                            "Writing 2 duplicate entries to trigger 2 events "
                            + "(with null template)");
 
@@ -350,13 +337,12 @@ public class RegisterForAvailabilityEven
                 templates, null, false,
                 testEventListener6a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener6a.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, null, leaseForeverTime);
         space.write(sampleEntry3, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener6a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events " +
                            "(with multiple matching templates)");
         registrations.add(er6a);

Modified: 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TestEventListener05.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TestEventListener05.java?rev=1486580&r1=1486579&r2=1486580&view=diff
==============================================================================
--- 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TestEventListener05.java
 (original)
+++ 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TestEventListener05.java
 Mon May 27 11:21:16 2013
@@ -85,6 +85,10 @@ public class TestEventListener05 impleme
     public synchronized List getNotifications() {
         return new ArrayList(notifications);
     }
+    
+    public synchronized void clearNotifications() {
+        notifications.clear();
+    }
 
     public synchronized Object writeReplace() throws ObjectStreamException {
         return proxy;

Modified: 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TransactionRegisterForAvailabilityEventTest05.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TransactionRegisterForAvailabilityEventTest05.java?rev=1486580&r1=1486579&r2=1486580&view=diff
==============================================================================
--- 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TransactionRegisterForAvailabilityEventTest05.java
 (original)
+++ 
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/javaspace/conformance/TransactionRegisterForAvailabilityEventTest05.java
 Mon May 27 11:21:16 2013
@@ -43,12 +43,12 @@ import com.sun.jini.qa.harness.QAConfig;
 public class TransactionRegisterForAvailabilityEventTest05
         extends TransactionTest
 {
-    private ArrayList templates = new ArrayList();
-    private ArrayList expectedResult = new ArrayList();
+    private final ArrayList templates = new ArrayList();
+    private final ArrayList expectedResult = new ArrayList();
 
-    private SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
-    private SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
-    private SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
+    private final SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 
1);
+    private final SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 
2);
+    private final SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 
2);
 
     /**
      * This method asserts that for JavaSpace05's
@@ -98,7 +98,7 @@ public class TransactionRegisterForAvail
      *
      * @throws Exception
      */
-    public void run() throws Exception {
+    public synchronized void run() throws Exception {
         Transaction txn = getTransaction();
         ArrayList registrations = new ArrayList();
 
@@ -112,11 +112,10 @@ public class TransactionRegisterForAvail
                 txn, true, testEventListener0, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
         final long gotER0Timestamp = System.currentTimeMillis();
-        List notifications = testEventListener0.getNotifications();
         expectedResult.add(sampleEntry1);  // this entry is to trigger the 
event
         space.write(sampleEntry1, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener0.getNotifications(), 
expectedResult,
                            "Writing one entry to trigger an event");
         registrations.add(er0);
         reset(txn);
@@ -127,13 +126,12 @@ public class TransactionRegisterForAvail
         EventRegistration er1 = space05.registerForAvailabilityEvent(templates,
                 txn, true, testEventListener1, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener1.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, txn, leaseForeverTime);
         space.write(sampleEntry2, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener1.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events");
         registrations.add(er1);
         reset(txn);
@@ -143,13 +141,12 @@ public class TransactionRegisterForAvail
         EventRegistration er2 = space05.registerForAvailabilityEvent(templates,
                 txn, true, testEventListener2, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener2.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, txn, leaseForeverTime);
         space.write(sampleEntry3, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener2.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events "
                            + "(with single template)");
         registrations.add(er2);
@@ -160,7 +157,6 @@ public class TransactionRegisterForAvail
         EventRegistration er3 = space05.registerForAvailabilityEvent(templates,
                 txn, true, testEventListener3, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener3.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
@@ -168,7 +164,7 @@ public class TransactionRegisterForAvail
         space.write(sampleEntry2, txn, leaseForeverTime);
         space.write(sampleEntry3, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener3.getNotifications(), 
expectedResult,
                            "Writing 3 entries to trigger 3 events "
                            + "(with single template)");
         registrations.add(er3);
@@ -179,13 +175,12 @@ public class TransactionRegisterForAvail
         EventRegistration er4 = space05.registerForAvailabilityEvent(templates,
                 txn, true, testEventListener4, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener4.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, txn, leaseForeverTime);
         space.write(sampleEntry2, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener4.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events "
                            + "(with null template)");
         registrations.add(er4);
@@ -196,13 +191,12 @@ public class TransactionRegisterForAvail
         EventRegistration er5 = space05.registerForAvailabilityEvent(templates,
                 txn, true, testEventListener5, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener5.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry1);
         space.write(sampleEntry1, txn, leaseForeverTime);
         space.write(sampleEntry1, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener5.getNotifications(), 
expectedResult,
                            "Writing 2 duplicate entries to trigger 2 events "
                            + "(with null template)");
 
@@ -222,13 +216,12 @@ public class TransactionRegisterForAvail
         EventRegistration er6 = space05.registerForAvailabilityEvent(templates,
                 txn, true, testEventListener6, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener6.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, txn, leaseForeverTime);
         space.write(sampleEntry3, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener6.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events " +
                            "(with multiple matching templates)");
         registrations.add(er6);
@@ -245,11 +238,10 @@ public class TransactionRegisterForAvail
                 templates, txn, false,
                 testEventListener0a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener0a.getNotifications();
         expectedResult.add(sampleEntry1);  // this entry is to trigger the 
event
         space.write(sampleEntry1, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener0a.getNotifications(), 
expectedResult,
                            "Writing one entry to trigger an event");
         registrations.add(er0a);
         reset(txn);
@@ -261,13 +253,12 @@ public class TransactionRegisterForAvail
                 templates, txn, false,
                 testEventListener1a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener1a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, txn, leaseForeverTime);
         space.write(sampleEntry2, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener1a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events");
         registrations.add(er1a);
         reset(txn);
@@ -278,13 +269,12 @@ public class TransactionRegisterForAvail
                 templates, txn, false,
                 testEventListener2a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener2a.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, txn, leaseForeverTime);
         space.write(sampleEntry3, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener2a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events "
                            + "(with single template)");
         registrations.add(er2a);
@@ -296,7 +286,6 @@ public class TransactionRegisterForAvail
                 templates, txn, false,
                 testEventListener3a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener3a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
@@ -304,7 +293,7 @@ public class TransactionRegisterForAvail
         space.write(sampleEntry2, txn, leaseForeverTime);
         space.write(sampleEntry3, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener3a.getNotifications(), 
expectedResult,
                            "Writing 3 entries to trigger 3 events "
                            + "(with single template)");
         registrations.add(er3a);
@@ -316,13 +305,12 @@ public class TransactionRegisterForAvail
                 templates, txn, false,
                 testEventListener4a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener4a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry2);
         space.write(sampleEntry1, txn, leaseForeverTime);
         space.write(sampleEntry2, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener4a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events "
                            + "(with null template)");
         registrations.add(er4a);
@@ -334,13 +322,12 @@ public class TransactionRegisterForAvail
                 templates, txn, false,
                 testEventListener5a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener5a.getNotifications();
         expectedResult.add(sampleEntry1);
         expectedResult.add(sampleEntry1);
         space.write(sampleEntry1, txn, leaseForeverTime);
         space.write(sampleEntry1, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener5a.getNotifications(), 
expectedResult,
                            "Writing 2 duplicate entries to trigger 2 events "
                            + "(with null template)");
 
@@ -361,13 +348,12 @@ public class TransactionRegisterForAvail
                 templates, txn, false,
                 testEventListener6a, leaseForeverTime,
                 new MarshalledObject("notUsedHere"));
-        notifications = testEventListener6a.getNotifications();
         expectedResult.add(sampleEntry2);
         expectedResult.add(sampleEntry3);
         space.write(sampleEntry2, txn, leaseForeverTime);
         space.write(sampleEntry3, txn, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener6a.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger 2 events " +
                            "(with multiple matching templates)");
         registrations.add(er6a);
@@ -416,12 +402,11 @@ public class TransactionRegisterForAvail
          * The expectedResult is empty.
          */
         Thread.sleep(2000);     // let the time for registrations to be dropped
-        notifications = testEventListener2.getNotifications();
-        notifications.clear(); // clear all the previous notifications
+        testEventListener2.clearNotifications(); // clear all the previous 
notifications
         space.write(sampleEntry2, null, leaseForeverTime);
         space.write(sampleEntry3, null, leaseForeverTime);
         Thread.sleep(waitingNotificationsToComeTime);
-        checkNotifications(notifications, expectedResult,
+        checkNotifications(testEventListener2.getNotifications(), 
expectedResult,
                            "Writing 2 entries to trigger no events " +
                            "(registration dropped)");
         cleanSpace(space);


Reply via email to