You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2013/09/24 03:54:39 UTC

[3/4] git commit: When performBackgroundOperation gets a retryable CuratorConnectionLossException, don't do it inline. Queue the background operation as usual

When performBackgroundOperation gets a retryable CuratorConnectionLossException, don't do it inline. Queue the background operation as usual


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

Branch: refs/heads/master
Commit: 64a21a79c5c8bbb9f5b36dfdfd7adbec72795af3
Parents: a561f9a
Author: randgalt <ra...@apache.org>
Authored: Sun Sep 22 17:53:53 2013 -0700
Committer: randgalt <ra...@apache.org>
Committed: Sun Sep 22 17:53:53 2013 -0700

----------------------------------------------------------------------
 .../framework/imps/CuratorFrameworkImpl.java    | 43 ++++++++++----------
 1 file changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/64a21a79/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 3cccf45..87353bf 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
@@ -667,32 +667,33 @@ public class CuratorFrameworkImpl implements CuratorFramework
 
     private void performBackgroundOperation(OperationAndData<?> operationAndData)
     {
-        boolean isDone = false;
-        while ( !isDone )
+        try
         {
-            try
-            {
-                operationAndData.callPerformBackgroundOperation();
-                isDone = true;
-            }
-            catch ( Throwable e )
+            operationAndData.callPerformBackgroundOperation();
+        }
+        catch ( Throwable e )
+        {
+            /**
+             * Fix edge case reported as CURATOR-52. ConnectionState.checkTimeouts() throws KeeperException.ConnectionLossException
+             * when the initial (or previously failed) connection cannot be re-established. This needs to be run through the retry policy
+             * and callbacks need to get invoked, etc.
+             */
+            if ( e instanceof CuratorConnectionLossException )
             {
-                /**
-                 * Fix edge case reported as CURATOR-52. ConnectionState.checkTimeouts() throws KeeperException.ConnectionLossException
-                 * when the initial (or previously failed) connection cannot be re-established. This needs to be run through the retry policy
-                 * and callbacks need to get invoked, etc.
-                 */
-                if ( e instanceof CuratorConnectionLossException )
+                WatchedEvent watchedEvent = new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState.Disconnected, null);
+                CuratorEvent event = new CuratorEventImpl(this, CuratorEventType.WATCHED, KeeperException.Code.CONNECTIONLOSS.intValue(), null, null, operationAndData.getContext(), null, null, null, watchedEvent, null);
+                if ( checkBackgroundRetry(operationAndData, event) )
                 {
-                    WatchedEvent watchedEvent = new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState.Disconnected, null);
-                    CuratorEvent event = new CuratorEventImpl(this, CuratorEventType.WATCHED, KeeperException.Code.CONNECTIONLOSS.intValue(), null, null, operationAndData.getContext(), null, null, null, watchedEvent, null);
-                    if ( checkBackgroundRetry(operationAndData, event) )
-                    {
-                        continue;
-                    }
+                    queueOperation(operationAndData);
+                }
+                else
+                {
+                    handleBackgroundOperationException(operationAndData, e);
                 }
+            }
+            else
+            {
                 handleBackgroundOperationException(operationAndData, e);
-                isDone = true;
             }
         }
     }