Repository: curator Updated Branches: refs/heads/master 26fcc3cf2 -> eebff920c
fix path used when re-creating sequential PersistentNode with protection would previously result in creation of a second non-sequential znode Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/91e3a643 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/91e3a643 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/91e3a643 Branch: refs/heads/master Commit: 91e3a643ff6c562d30e75a61ed2d626befbcc40c Parents: 26fcc3c Author: nickhill <[email protected]> Authored: Fri Nov 2 16:51:15 2018 -0700 Committer: nickhill <[email protected]> Committed: Fri Nov 2 16:51:15 2018 -0700 ---------------------------------------------------------------------- .../curator/framework/recipes/nodes/PersistentNode.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/91e3a643/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 bdf607c..9c9b527 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 @@ -445,7 +445,8 @@ public class PersistentNode implements Closeable try { String existingPath = nodePath.get(); - String createPath = (existingPath != null && !useProtection) ? existingPath : basePath; + String createPath = existingPath == null || (useProtection && !isSequential(mode)) ? basePath + : (useProtection ? basePath + existingPath.substring(existingPath.length()-10) : existingPath); CreateModable<ACLBackgroundPathAndBytesable<String>> localCreateMethod = createMethod.get(); if ( localCreateMethod == null ) @@ -463,6 +464,10 @@ public class PersistentNode implements Closeable throw new RuntimeException("Creating node. BasePath: " + basePath, e); // should never happen unless there's a programming error - so throw RuntimeException } } + + private static boolean isSequential(CreateMode mode) { + return mode == CreateMode.EPHEMERAL_SEQUENTIAL || mode == CreateMode.PERSISTENT_SEQUENTIAL; + } private CreateMode getCreateMode(boolean pathIsSet) {
