You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/06/01 00:06:43 UTC
[5/5] 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
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-3.0
Commit: e2200daad2b04d721a99374686b52758bc012e12
Parents: 44fd666
Author: randgalt <ra...@apache.org>
Authored: Tue May 31 10:35:10 2016 -0500
Committer: randgalt <ra...@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;
}
}
}