curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cameron McKenzie (JIRA)" <>
Subject [jira] [Commented] (CURATOR-179) Sequential path creation of /somepath/N throws exception
Date Wed, 07 Jan 2015 21:11:34 GMT


Cameron McKenzie commented on CURATOR-179:

In the path validation code in ZK itself (where I believe the Curator PathUtils class was
borrowed from) "/foo/" is illegal. The exception is for sequential paths because they get
a number appended to them which is what's happening in this case.

In the context of the fixForNamespace() method, there's no difference between "/foo/" and
"/foo" because I believe that the call to makePaths() fixes the path even if it ends with
a "/", though this would only happen if a namespace was active, so this is a bit inconsistent.
I don't know if we could just make fixForNamespace() remove any trailing slash, it might break
the sequential stuff.

> Sequential path creation of /somepath/N throws exception
> --------------------------------------------------------
>                 Key: CURATOR-179
>                 URL:
>             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(
> [error] 	at org.apache.curator.utils.ZKPaths.fixForNamespace(
> [error] 	at org.apache.curator.framework.imps.NamespaceImpl.fixForNamespace(
> [error] 	at org.apache.curator.framework.imps.CuratorFrameworkImpl.fixForNamespace(
> [error] 	at org.apache.curator.framework.imps.CreateBuilderImpl$1.forPath(
> [error] 	at org.apache.curator.framework.imps.CreateBuilderImpl$1.forPath(
> [error] 	at<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
> 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

View raw message