From 302661a7af89d4101a9751acfa4897c45fcc44d9 Mon Sep 17 00:00:00 2001 From: randgalt Date: Mon, 17 Apr 2017 13:58:15 -0500 Subject: [PATCH] localCreateMethod could be null in a race condition --- .../curator/framework/recipes/nodes/PersistentNode.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 5753a93e15..97ad7948b8 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 @@ private void createNode() if ( localCreateMethod == null ) { CreateModable> 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()); }