Background operations were not checking if the client was connected. Further, 
the connection timeout was not being respected as it is in foreground operations


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/9299e9bb
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/9299e9bb
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/9299e9bb

Branch: refs/heads/CURATOR-72
Commit: 9299e9bbf889470dae8b7c14956a23f73e8097db
Parents: 28b63b0
Author: randgalt <randg...@apache.org>
Authored: Sat Nov 9 18:46:59 2013 -0800
Committer: randgalt <randg...@apache.org>
Committed: Sat Nov 9 18:46:59 2013 -0800

----------------------------------------------------------------------
 .../framework/imps/CuratorFrameworkImpl.java        | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/9299e9bb/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index 87353bf..d56c9a4 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -50,6 +50,7 @@ import java.util.concurrent.DelayQueue;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
 public class CuratorFrameworkImpl implements CuratorFramework
@@ -669,7 +670,20 @@ public class CuratorFrameworkImpl implements 
CuratorFramework
     {
         try
         {
-            operationAndData.callPerformBackgroundOperation();
+            if ( client.isConnected() )
+            {
+                operationAndData.callPerformBackgroundOperation();
+            }
+            else
+            {
+                client.getZooKeeper();  // important - allow connection 
resets, timeouts, etc. to occur
+                if ( operationAndData.getElapsedTimeMs() >= 
client.getConnectionTimeoutMs() )
+                {
+                    throw new CuratorConnectionLossException();
+                }
+                operationAndData.sleepFor(1, TimeUnit.SECONDS);
+                queueOperation(operationAndData);
+            }
         }
         catch ( Throwable e )
         {

Reply via email to