Repository: curator Updated Branches: refs/heads/CURATOR-490 9f12a189c -> 9c5aa12dc
CURATOR-490 - found another instance where a backround callback could be called after the instance is closed. If after re-testing this fixes the Jenkins problem I'll create a separate ticket for this Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/9c5aa12d Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/9c5aa12d Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/9c5aa12d Branch: refs/heads/CURATOR-490 Commit: 9c5aa12dc0b5b555647b46a569f0f967890c2467 Parents: 9f12a18 Author: randgalt <[email protected]> Authored: Fri Dec 7 12:04:04 2018 -0500 Committer: randgalt <[email protected]> Committed: Fri Dec 7 12:04:04 2018 -0500 ---------------------------------------------------------------------- .../recipes/cache/PathChildrenCache.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/9c5aa12d/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java index f8c4e93..9b6951d 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java @@ -492,9 +492,8 @@ public class PathChildrenCache implements Closeable @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { - if (PathChildrenCache.this.state.get().equals(State.CLOSED)) { - // This ship is closed, don't handle the callback - PathChildrenCache.this.client.removeWatchers(); + if ( reRemoveWatchersOnBackgroundClosed() ) + { return; } if ( event.getResultCode() == KeeperException.Code.OK.intValue() ) @@ -552,6 +551,10 @@ public class PathChildrenCache implements Closeable @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { + if ( reRemoveWatchersOnBackgroundClosed() ) + { + return; + } applyNewData(fullPath, event.getResultCode(), event.getStat(), cacheData ? event.getData() : null); } }; @@ -606,6 +609,16 @@ public class PathChildrenCache implements Closeable } } + private boolean reRemoveWatchersOnBackgroundClosed() + { + if ( state.get().equals(State.CLOSED)) { + // This ship is closed, don't handle the callback + client.removeWatchers(); + return true; + } + return false; + } + private void internalRebuildNode(String fullPath) throws Exception { if ( cacheData )
