[ 
https://issues.apache.org/jira/browse/CURATOR-499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16739646#comment-16739646
 ] 

ASF GitHub Bot commented on CURATOR-499:
----------------------------------------

GitHub user marquiswang opened a pull request:

    https://github.com/apache/curator/pull/300

    CURATOR-499 Allow creating sequential nodes with an empty name

    Add CreateModable#withMode(CreateMode, PathEncodingType) where
    PathEncodingType is an enum with values DEFAULT and ALLOW_EMPTY.
    
    When a node is created with ALLOW_EMPTY, trailing /s will not be
    removed from the path.
    
    This should not be used except with sequential CreateModes, as it will
    fail with:
    java.lang.IllegalArgumentException: Path must not end with / character
    
    Calling the following:
    
    curatorFramework.create()
        .withMode(CreateMode.PERSISTENT_SEQUENTIAL, 
PathEncodingType.ALLOW_EMPTY)
        .forPath("/foo/bar/, data);
    
    Will create a node "/foo/bar/000000000X", whereas calling:
    
    curatorFramework.create()
        .withMode(CreateMode.PERSISTENT_SEQUENTIAL)
        .forPath("/foo/bar/, data);
    
    Will create a node "/foo/bar000000000X".

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/marquiswang/curator master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/curator/pull/300.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #300
    
----
commit df2ad2a27eeeb21a30dd1a7e9c05416d23b22d2a
Author: Marquis Wong <marquis.wong@...>
Date:   2019-01-10T17:20:22Z

    CURATOR-499 Allow creating sequential nodes with an empty name
    
    Add CreateModable#withMode(CreateMode, PathEncodingType) where
    PathEncodingType is an enum with values DEFAULT and ALLOW_EMPTY.
    
    When a node is created with ALLOW_EMPTY, trailing /s will not be
    removed from the path.
    
    This should not be used except with sequential CreateModes, as it will
    fail with:
    java.lang.IllegalArgumentException: Path must not end with / character
    
    Calling the following:
    
    curatorFramework.create()
        .withMode(CreateMode.PERSISTENT_SEQUENTIAL, 
PathEncodingType.ALLOW_EMPTY)
        .forPath("/foo/bar/, data);
    
    Will create a node "/foo/bar/000000000X", whereas calling:
    
    curatorFramework.create()
        .withMode(CreateMode.PERSISTENT_SEQUENTIAL)
        .forPath("/foo/bar/, data);
    
    Will create a node "/foo/bar000000000X".

----


> ZKPaths strips trailing "/" incorrectly when creating sequential nodes
> ----------------------------------------------------------------------
>
>                 Key: CURATOR-499
>                 URL: https://issues.apache.org/jira/browse/CURATOR-499
>             Project: Apache Curator
>          Issue Type: Bug
>            Reporter: Marquis Wang
>            Assignee: Jordan Zimmerman
>            Priority: Minor
>
> I think this was introduced in CURATOR-166, which changed ZKPaths to strip 
> trailing slashes from child nodes.
> This is fine in most cases: it made it so 
> {code:java}
> curatorFramework.create()
>     .forPath("/path/to/node/", data);{code}
> would create a node at {{/path/to/node}}.
> However, if you want to create a sequential node:
> {code:java}
> curatorFramework.create()
>     .withMode(CreateMode.PERSISTENT_SEQUENTIAL)
>     .forPath("/path/to/node/", data);{code}
> In clients after CURATOR-166 (2.7.1 and higher), this will create a node 
> {{/path/to/node00000001}}. Before, and if you call the zookeeper cli with the 
> same options, it would create a node {{/path/to/node/00000001}}.
> This effectively makes it so you cannot use curator to create sequential 
> nodes where the entire node name is the sequence number.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to