curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject curator git commit: it takes time for the watcher removals to settle due to async/watchers, etc. So, if there are remaining watchers, sleep a bit
Date Tue, 31 May 2016 15:35:14 GMT
Repository: curator
Updated Branches:
  refs/heads/CURATOR-332 44fd666a3 -> e2200daad


it takes time for the watcher removals to settle due to async/watchers, etc. So, if there
are remaining watchers, sleep a bit


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/e2200daa
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/e2200daa
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/e2200daa

Branch: refs/heads/CURATOR-332
Commit: e2200daad2b04d721a99374686b52758bc012e12
Parents: 44fd666
Author: randgalt <randgalt@apache.org>
Authored: Tue May 31 10:35:10 2016 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Tue May 31 10:35:10 2016 -0500

----------------------------------------------------------------------
 .../curator/framework/imps/TestCleanState.java  | 42 +++++++++++++++-----
 1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/e2200daa/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
index aa759ee..9d90616 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCleanState.java
@@ -48,17 +48,39 @@ public class TestCleanState
             ZooKeeper zooKeeper = internalClient.getZooKeeper();
             if ( zooKeeper != null )
             {
-                if ( WatchersDebug.getChildWatches(zooKeeper).size() != 0 )
+                final int maxLoops = 3;
+                for ( int i = 0; i < maxLoops; ++i )    // it takes time for the watcher
removals to settle due to async/watchers, etc. So, if there are remaining watchers, sleep
a bit
                 {
-                    throw new AssertionError("One or more child watchers are still registered:
" + WatchersDebug.getChildWatches(zooKeeper));
-                }
-                if ( WatchersDebug.getExistWatches(zooKeeper).size() != 0 )
-                {
-                    throw new AssertionError("One or more exists watchers are still registered:
" + WatchersDebug.getExistWatches(zooKeeper));
-                }
-                if ( WatchersDebug.getDataWatches(zooKeeper).size() != 0 )
-                {
-                    throw new AssertionError("One or more data watchers are still registered:
" + WatchersDebug.getDataWatches(zooKeeper));
+                    if ( i > 0 )
+                    {
+                        Thread.sleep(500);
+                    }
+                    boolean isLast = (i + 1) == maxLoops;
+                    if ( WatchersDebug.getChildWatches(zooKeeper).size() != 0 )
+                    {
+                        if ( isLast )
+                        {
+                            throw new AssertionError("One or more child watchers are still
registered: " + WatchersDebug.getChildWatches(zooKeeper));
+                        }
+                        continue;
+                    }
+                    if ( WatchersDebug.getExistWatches(zooKeeper).size() != 0 )
+                    {
+                        if ( isLast )
+                        {
+                            throw new AssertionError("One or more exists watchers are still
registered: " + WatchersDebug.getExistWatches(zooKeeper));
+                        }
+                        continue;
+                    }
+                    if ( WatchersDebug.getDataWatches(zooKeeper).size() != 0 )
+                    {
+                        if ( isLast )
+                        {
+                            throw new AssertionError("One or more data watchers are still
registered: " + WatchersDebug.getDataWatches(zooKeeper));
+                        }
+                        continue;
+                    }
+                    break;
                 }
             }
         }


Mime
View raw message