zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1582059 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/test/org/apache/zookeeper/TestableZooKeeper.java src/java/test/org/apache/zookeeper/test/WatcherTest.java
Date Wed, 26 Mar 2014 21:16:40 GMT
Author: michim
Date: Wed Mar 26 21:16:39 2014
New Revision: 1582059

URL: http://svn.apache.org/r1582059
Log:
ZOOKEEPER-1904. WatcherTest#testWatchAutoResetWithPending is failing (Rakesh R via michim)

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/TestableZooKeeper.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/WatcherTest.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1582059&r1=1582058&r2=1582059&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Wed Mar 26 21:16:39 2014
@@ -263,6 +263,9 @@ BUGFIXES:
   ZOOKEEPER-1755. Concurrent operations of four letter 'dump' ephemeral 
   command and killSession causing NPE (Rakesh R via camille)
 
+  ZOOKEEPER-1904. WatcherTest#testWatchAutoResetWithPending is failing
+  (Rakesh R via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1564. Allow JUnit test build with IBM Java

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/TestableZooKeeper.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/TestableZooKeeper.java?rev=1582059&r1=1582058&r2=1582059&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/TestableZooKeeper.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/TestableZooKeeper.java
Wed Mar 26 21:16:39 2014
@@ -21,6 +21,8 @@ package org.apache.zookeeper;
 import java.io.IOException;
 import java.net.SocketAddress;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.jute.Record;
 import org.apache.zookeeper.proto.ReplyHeader;
@@ -64,8 +66,10 @@ public class TestableZooKeeper extends Z
      * Cause this ZooKeeper object to stop receiving from the ZooKeeperServer
      * for the given number of milliseconds.
      * @param ms the number of milliseconds to pause.
+     * @return true if the connection is paused, otherwise false
      */
-    public void pauseCnxn(final long ms) {
+    public boolean pauseCnxn(final long ms) {
+        final CountDownLatch initiatedPause = new CountDownLatch(1);
         new Thread() {
             public void run() {
                 synchronized(cnxn) {
@@ -74,6 +78,8 @@ public class TestableZooKeeper extends Z
                             cnxn.sendThread.testableCloseSocket();
                         } catch (IOException e) {
                             e.printStackTrace();
+                        } finally {
+                            initiatedPause.countDown();
                         }
                         Thread.sleep(ms);
                     } catch (InterruptedException e) {
@@ -81,6 +87,13 @@ public class TestableZooKeeper extends Z
                 }
             }
         }.start();
+
+        try {
+            return initiatedPause.await(ms, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            return false;
+        }
     }
     
     public boolean testableWaitForShutdown(int wait)

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/WatcherTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/WatcherTest.java?rev=1582059&r1=1582058&r2=1582059&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/WatcherTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/WatcherTest.java
Wed Mar 26 21:16:39 2014
@@ -195,8 +195,7 @@ public class WatcherTest extends ClientB
            zk.exists("/test", watches[i], cbs[i], count);
        }
        zk.exists("/test", false);
-       zk.pauseCnxn(3000);
-       Thread.sleep(50);
+       Assert.assertTrue("Failed to pause the connection!", zk.pauseCnxn(3000));
        zk2.close();
        stopServer();
        watches[0].waitForDisconnected(60000);



Mime
View raw message