Repository: curator
Updated Branches:
  refs/heads/CURATOR-395 [created] 302661a7a


localCreateMethod could be null in a race condition


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

Branch: refs/heads/CURATOR-395
Commit: 302661a7af89d4101a9751acfa4897c45fcc44d9
Parents: 9febe31
Author: randgalt <randg...@apache.org>
Authored: Mon Apr 17 13:58:15 2017 -0500
Committer: randgalt <randg...@apache.org>
Committed: Mon Apr 17 13:58:15 2017 -0500

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/nodes/PersistentNode.java | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/302661a7/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
----------------------------------------------------------------------
diff --git 
a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
 
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
index 5753a93..97ad794 100644
--- 
a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
+++ 
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/nodes/PersistentNode.java
@@ -374,10 +374,8 @@ public class PersistentNode implements Closeable
             if ( localCreateMethod == null )
             {
                 CreateModable<ACLBackgroundPathAndBytesable<String>> 
tempCreateMethod = useProtection ? 
client.create().creatingParentContainersIfNeeded().withProtection() : 
client.create().creatingParentContainersIfNeeded();
-                if ( createMethod.compareAndSet(null, tempCreateMethod) )
-                {
-                    localCreateMethod = tempCreateMethod;
-                }
+                createMethod.compareAndSet(null, tempCreateMethod);
+                localCreateMethod = createMethod.get();
             }
             localCreateMethod.withMode(getCreateMode(existingPath != 
null)).inBackground(backgroundCallback).forPath(createPath, data.get());
         }

Reply via email to