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

backgroundCreateParentsThenNode() ignores exceptions too crudely

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 3.2.0, 2.11.1
    • 3.3.0, 2.12.0
    • Framework
    • None

    Description

      backgroundCreateParentsThenNode() in CreateBuilderImpl,java is ignoring all KeeperExceptions. This can cause an infinite loop if the KeeperException is not an ignorable one.

      Here's a code snippet that shows the problem:

      @Test
      public void testIt() throws Exception
      {
          ACLProvider provider = new ACLProvider()
          {
              @Override
              public List<ACL> getDefaultAcl()
              {
                  return ZooDefs.Ids.OPEN_ACL_UNSAFE;
              }
      
              @Override
              public List<ACL> getAclForPath(String path)
              {
                  if ( path.equals("/ns/one") )
                  {
                      try
                      {
                          return Collections.singletonList(new ACL(ZooDefs.Perms.ALL, new Id("digest", DigestAuthenticationProvider.generateDigest("test"))));
                      }
                      catch ( NoSuchAlgorithmException e )
                      {
                          e.printStackTrace();
                      }
                  }
                  return getDefaultAcl();
              }
          };
          try ( CuratorFramework client = createClient(provider, new AuthInfo("digest", DigestAuthenticationProvider.generateDigest("test").getBytes())) )
          {
              LeaderLatch latch = new LeaderLatch(client, "/one/two");
              latch.start();
              latch.await();
              System.err.println("hdeherherhe");
          }
      }
      
      private CuratorFramework createClient(ACLProvider provider, AuthInfo authInfo) throws Exception
      {
          RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
          CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
              .namespace("ns")
              .connectString(server.getConnectString())
              .retryPolicy(retryPolicy)
              ;
          if ( provider != null )
          {
              builder = builder.aclProvider(provider);
          }
          if ( authInfo != null )
          {
              builder = builder.authorization(authInfo.getScheme(), authInfo.getAuth());
          }
          CuratorFramework client = builder.build();
          client.start();
          return client;
      }
      

      While this is running you can put a breakpoint on CreateBuilderImpl#findProtectedNodeInForeground() and see it get called over and over.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: