Support client timeouts < 1000ms 274/head
authorMartin Betak <matobet@gmail.com>
Wed, 8 Aug 2018 11:51:28 +0000 (13:51 +0200)
committerMartin Betak <matobet@gmail.com>
Wed, 8 Aug 2018 11:51:28 +0000 (13:51 +0200)
Before, regardless of the value set in `connectionTimeoutMs` the
CuratorZookeeperClient#internalBlockUntilConnectedOrTimedOut method did
the initial wait with value of 1 second, which made settings lower than
this value ineffective. This proved problematic in several use cases
where such minimum for timeout is prohibitively large.

curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java

index 5032117..7977541 100644 (file)
@@ -428,9 +428,10 @@ public class CuratorZookeeperClient implements Closeable
 
             state.addParentWatcher(tempWatcher);
             long startTimeMs = System.currentTimeMillis();
+            long timeoutMs = Math.min(waitTimeMs, 1000);
             try
             {
-                latch.await(1, TimeUnit.SECONDS);
+                latch.await(timeoutMs, TimeUnit.MILLISECONDS);
             }
             finally
             {