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
- links to