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 2017/01/26 17:49:29 UTC
[21/40] curator git commit: Original PR breaks nodes with protection
as the protection ID is stored in the create builder. This change fixes it.
Original PR breaks nodes with protection as the protection ID is stored in the create builder. This change fixes it.
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0b699a36
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0b699a36
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0b699a36
Branch: refs/heads/persistent-watch
Commit: 0b699a368bbb5f3c72ab609fa590bf225c2a2d7a
Parents: 144977f
Author: randgalt <ra...@apache.org>
Authored: Mon Jan 9 14:22:59 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jan 9 14:22:59 2017 -0500
----------------------------------------------------------------------
.../framework/recipes/nodes/PersistentNode.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/0b699a36/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 45f74ca..1f655ed 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
@@ -68,6 +68,7 @@ public class PersistentNode implements Closeable
private final AtomicBoolean authFailure = new AtomicBoolean(false);
private final BackgroundCallback backgroundCallback;
private final boolean useProtection;
+ private final AtomicReference<CreateModable<ACLBackgroundPathAndBytesable<String>>> createMethod = new AtomicReference<CreateModable<ACLBackgroundPathAndBytesable<String>>>(null);
private final CuratorWatcher watcher = new CuratorWatcher()
{
@Override
@@ -364,9 +365,16 @@ public class PersistentNode implements Closeable
String existingPath = nodePath.get();
String createPath = (existingPath != null && !useProtection) ? existingPath : basePath;
- CreateModable<ACLBackgroundPathAndBytesable<String>> createMethod = useProtection ?
- client.create().creatingParentContainersIfNeeded().withProtection() : client.create().creatingParentContainersIfNeeded();
- createMethod.withMode(getCreateMode(existingPath != null)).inBackground(backgroundCallback).forPath(createPath, data.get());
+ CreateModable<ACLBackgroundPathAndBytesable<String>> localCreateMethod = createMethod.get();
+ if ( localCreateMethod == null )
+ {
+ CreateModable<ACLBackgroundPathAndBytesable<String>> tempCreateMethod = useProtection ? client.create().creatingParentContainersIfNeeded().withProtection() : client.create().creatingParentContainersIfNeeded();
+ if ( createMethod.compareAndSet(null, tempCreateMethod) )
+ {
+ localCreateMethod = tempCreateMethod;
+ }
+ }
+ localCreateMethod.withMode(getCreateMode(existingPath != null)).inBackground(backgroundCallback).forPath(createPath, data.get());
}
catch ( Exception e )
{