CURATOR-240: fix pathological "root doesn't exist" infinite refresh cycle


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

Branch: refs/heads/CURATOR-167
Commit: 3a4d541a383a1a42c1f605056d75d36da26a76c5
Parents: c3426ba
Author: Scott Blum <dragonsi...@apache.org>
Authored: Fri Jul 31 17:19:14 2015 -0400
Committer: Scott Blum <dragonsi...@apache.org>
Committed: Fri Jul 31 17:19:14 2015 -0400

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/cache/TreeCache.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/3a4d541a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
----------------------------------------------------------------------
diff --git 
a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
 
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index 7cf2267..4f3ffb6 100644
--- 
a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ 
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@ -301,7 +301,8 @@ public class TreeCache implements Closeable
                 return;
             }
 
-            if ( nodeState.compareAndSet(NodeState.LIVE, NodeState.DEAD) )
+            NodeState oldState = nodeState.getAndSet(NodeState.DEAD);
+            if ( oldState == NodeState.LIVE )
             {
                 publishEvent(TreeCacheEvent.Type.NODE_REMOVED, path);
             }
@@ -363,10 +364,6 @@ public class TreeCache implements Closeable
                     nodeState.compareAndSet(NodeState.DEAD, NodeState.PENDING);
                     wasCreated();
                 }
-                else if ( event.getResultCode() == 
KeeperException.Code.NONODE.intValue() )
-                {
-                    wasDeleted();
-                }
                 break;
             case CHILDREN:
                 if ( event.getResultCode() == 
KeeperException.Code.OK.intValue() )
@@ -429,7 +426,8 @@ public class TreeCache implements Closeable
                     }
 
                     Stat oldStat = stat.getAndSet(newStat);
-                    if ( nodeState.compareAndSet(NodeState.PENDING, 
NodeState.LIVE) )
+                    NodeState oldState = nodeState.getAndSet(NodeState.LIVE);
+                    if ( oldState != NodeState.LIVE )
                     {
                         publishEvent(TreeCacheEvent.Type.NODE_ADDED, new 
ChildData(event.getPath(), newStat, event.getData()));
                     }

Reply via email to