[
https://issues.apache.org/jira/browse/CURATOR-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14077241#comment-14077241
]
Cameron McKenzie commented on CURATOR-128:
------------------------------------------
I think that it would be preferable to be consistent. So, "/" would refer to
the root of the namespace, or the root if non namespace is used.
To fix this without potentially breaking peoples code would rely on making "/"
and "" synonymous. I think it would be cleaner to always refer to the root as
"/" though.
> There is no namespace-safe way to refer to the root node
> --------------------------------------------------------
>
> Key: CURATOR-128
> URL: https://issues.apache.org/jira/browse/CURATOR-128
> Project: Apache Curator
> Issue Type: Bug
> Components: Framework
> Reporter: Scott Blum
>
> Add the following test to TestNamespaceFacade:
> {code}
> @Test
> public void testRootAccess() throws Exception
> {
> CuratorFramework client =
> CuratorFrameworkFactory.newClient(server.getConnectString(), new
> RetryOneTime(1));
> try
> {
> client.start();
> client.create().forPath("/one");
>
> Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/one",
> false));
> Assert.assertNotNull(client.checkExists().forPath("/"));
> try
> {
> client.checkExists().forPath("");
> Assert.fail("IllegalArgumentException expected");
> }
> catch ( IllegalArgumentException expected )
> {
> }
>
> Assert.assertNotNull(client.usingNamespace("one").checkExists().forPath(""));
> try
> {
> client.usingNamespace("one").checkExists().forPath("/");
> Assert.fail("IllegalArgumentException expected");
> }
> catch ( IllegalArgumentException expected )
> {
> }
> }
> finally
> {
> CloseableUtils.closeQuietly(client);
> }
> }
> {code}
> This tests PASSES, which means that there's no canonical way to refer to the
> root node. If the client is not namespaced, "/" works and "" does not work.
> If the client is namespaced, "" works and "/" does not.
> In either case, I think ZKPaths.makePath mishandles certain cases.
> If you append "/foo" and "/" the result is "/foo/" which is an invalid path.
> On the other hand, if you append "" and "bar" the result is "//bar" which is
> also invalid.
> What's the right behavior here? Does the root node / root of a namespace
> always need to be referred to as "/" or is empty string an acceptable alias?
--
This message was sent by Atlassian JIRA
(v6.2#6252)