Ryan Luecke created CURATOR-179:
-----------------------------------

             Summary: Sequential path creation of /somepath/N throws exception
                 Key: CURATOR-179
                 URL: https://issues.apache.org/jira/browse/CURATOR-179
             Project: Apache Curator
          Issue Type: Bug
          Components: Framework
    Affects Versions: 2.7.0
            Reporter: Ryan Luecke


A new error is thrown when attempting to run one of our scala services with 
Curator 2.7.0. The error does not throw in 2.6.0 (or in 2.5.0, which is when 
the original code was written. We were updating to 2.7.0).

Stack trace:
[error] Exception in thread "main" java.lang.IllegalArgumentException: Path 
must not end with / character
[error]         at 
org.apache.curator.utils.PathUtils.validatePath(PathUtils.java:61)
[error]         at 
org.apache.curator.utils.ZKPaths.fixForNamespace(ZKPaths.java:44)
[error]         at 
org.apache.curator.framework.imps.NamespaceImpl.fixForNamespace(NamespaceImpl.java:82)
[error]         at 
org.apache.curator.framework.imps.CuratorFrameworkImpl.fixForNamespace(CuratorFrameworkImpl.java:589)
[error]         at 
org.apache.curator.framework.imps.CreateBuilderImpl$1.forPath(CreateBuilderImpl.java:112)
[error]         at 
org.apache.curator.framework.imps.CreateBuilderImpl$1.forPath(CreateBuilderImpl.java:76)
[error]         at com.box.<application code>.scala:175)
...

This happens when we try to create node /somepath/N (where N is sequential zk 
node).

In Curator, PathUtils.validatePath has two signatures:
1. public static void validatePath(String path, boolean isSequential) throws 
IllegalArgumentException {
     validatePath(isSequential? path + "1": path);
   }
2. public static String validatePath(String path) throws 
IllegalArgumentException {
  ...
  throws if path ends in '/'
  ...
}

In our case, path /somepath/ does end in '/'

The way #1 calls #2 appears to be a hack (appending "1" to path in order to 
validate). This would have caused path validation to *succeed* for our case - 
however, the caller MUST call this #1 signature of validatePath. The code calls 
actually calls #2 instead.

2.5.0 released May 28, 2014
2.6.0 released July 11, 2014
* issue introduced
2.7.0 released November 3, 2014

I believe the issue was introduced on July 29 2014, when a call to #2 above was 
added to fixForNamespace(String namespace, String path) in
https://github.com/apache/curator/commit/96d2a55a03f8d0357f8f8cfa80a39a095d70667c

We've decided to workaround the issue at the moment. Our workaround is 
straightforward:
Change our sequential node path from /somepath/N
to /somepath/entry_N

Please get in touch if you need additional information to solve this issue. 
Thanks!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to