Description
Add the following test to TestNamespaceFacade:
@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); } }
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?