curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [5/9] curator git commit: Turns out FindAndDeleteProtectedNodeInBackground was causing a stack overflow. Reset the retry count before requeueing
Date Mon, 18 Jan 2016 00:29:56 GMT
Turns out FindAndDeleteProtectedNodeInBackground was causing a stack overflow. Reset the retry
count before requeueing


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

Branch: refs/heads/CURATOR-3.0
Commit: 737d2aa19f74a3988279c41068cbad28fc868f8a
Parents: 70846a6
Author: randgalt <randgalt@apache.org>
Authored: Thu Jan 14 22:40:24 2016 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Thu Jan 14 22:40:24 2016 -0500

----------------------------------------------------------------------
 .../imps/FindAndDeleteProtectedNodeInBackground.java     |  1 +
 .../apache/curator/framework/imps/OperationAndData.java  | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/737d2aa1/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
b/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
index 2fbd9dd..5b0f47c 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java
@@ -52,6 +52,7 @@ class FindAndDeleteProtectedNodeInBackground implements BackgroundOperation<Void
             @Override
             public void retriesExhausted(OperationAndData<Void> operationAndData)
             {
+                operationAndData.reset();
                 client.processBackgroundOperation(operationAndData, null);
             }
         };

http://git-wip-us.apache.org/repos/asf/curator/blob/737d2aa1/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
b/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
index 38f59a0..279eece 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/OperationAndData.java
@@ -38,7 +38,7 @@ class OperationAndData<T> implements Delayed, RetrySleeper
     private final ErrorCallback<T> errorCallback;
     private final AtomicInteger retryCount = new AtomicInteger(0);
     private final AtomicLong sleepUntilTimeMs = new AtomicLong(0);
-    private final long ordinal = nextOrdinal.getAndIncrement();
+    private final AtomicLong ordinal = new AtomicLong();
     private final Object context;
 
     interface ErrorCallback<T>
@@ -53,6 +53,13 @@ class OperationAndData<T> implements Delayed, RetrySleeper
         this.callback = callback;
         this.errorCallback = errorCallback;
         this.context = context;
+        reset();
+    }
+
+    void reset()
+    {
+        retryCount.set(0);
+        ordinal.set(nextOrdinal.getAndIncrement());
     }
 
     Object getContext()
@@ -121,7 +128,7 @@ class OperationAndData<T> implements Delayed, RetrySleeper
         {
             if ( o instanceof OperationAndData )
             {
-                diff = ordinal - ((OperationAndData)o).ordinal;
+                diff = ordinal.get() - ((OperationAndData)o).ordinal.get();
             }
         }
 


Mime
View raw message