don't do work if client is closed
Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/34700a05 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/34700a05 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/34700a05 Branch: refs/heads/CURATOR-3.0 Commit: 34700a0557672061ecc859b8b129e40b3f5c244e Parents: b25a8a3 Author: randgalt <randg...@apache.org> Authored: Sat Oct 10 16:49:06 2015 -0500 Committer: randgalt <randg...@apache.org> Committed: Sat Oct 10 16:49:06 2015 -0500 ---------------------------------------------------------------------- .../curator/framework/imps/EnsembleTracker.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/34700a05/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java index a46fed1..7dc1336 100644 --- a/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java +++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java @@ -122,18 +122,21 @@ public class EnsembleTracker implements Closeable, CuratorWatcher private void reset() throws Exception { - BackgroundCallback backgroundCallback = new BackgroundCallback() + if ( client.getState() == CuratorFrameworkState.STARTED ) { - @Override - public void processResult(CuratorFramework client, CuratorEvent event) throws Exception + BackgroundCallback backgroundCallback = new BackgroundCallback() { - if ( event.getType() == CuratorEventType.GET_CONFIG ) + @Override + public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { - processConfigData(event.getData()); + if ( event.getType() == CuratorEventType.GET_CONFIG ) + { + processConfigData(event.getData()); + } } - } - }; - client.getConfig().usingWatcher(this).inBackground(backgroundCallback).forEnsemble(); + }; + client.getConfig().usingWatcher(this).inBackground(backgroundCallback).forEnsemble(); + } } @VisibleForTesting