diff --git a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java index ecb072f65..1007b5988 100644 --- a/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java +++ b/curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java @@ -399,6 +399,9 @@ void removeParentWatcher(Watcher watcher) { public void internalBlockUntilConnectedOrTimedOut() throws InterruptedException { long waitTimeMs = connectionTimeoutMs; while (!state.isConnected() && (waitTimeMs > 0)) { + if (!started.get()) { + throw new IllegalStateException("Client is not started or has been closed"); + } final CountDownLatch latch = new CountDownLatch(1); Watcher tempWatcher = new Watcher() { @Override