Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-128

Enhance ZKPaths to be more lenient

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.7.0
    • Framework
    • None

    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?

      Attachments

        Activity

          People

            randgalt Jordan Zimmerman
            dragonsinth Scott Blum
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: