Github user hebelala commented on a diff in the pull request:
https://github.com/apache/curator/pull/291#discussion_r240040638
--- Diff:
curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
---
@@ -686,35 +693,66 @@ public void run()
}
else
{
- Assert.fail("unknown exception", e);
+ Assert.fail("unexpected exception", e);
}
}
finally
{
- countDownLatch.countDown();
+ log.info("client has deleted children, it costs:
{}ms", System.currentTimeMillis() - start);
+ latch.countDown();
}
}
}).start();
- Thread.sleep(20L);
- try
- {
- client2.delete().forPath("/parent/child" + (childCount /
2));
- }
- catch ( Exception e )
+ boolean threadDeleted = false;
+ boolean client2Deleted = false;
+ Random random = new Random();
+ for ( int i = 0; i < childCount; i++ )
{
- if ( e instanceof KeeperException.NoNodeException )
+ String child = "/parent/child" +
random.nextInt(childCount);
+ try
{
- Assert.fail("client2 delete failed, shouldn't throw
NoNodeException", e);
+ if ( !threadDeleted )
+ {
+ Stat stat = client2.checkExists().forPath(child);
+ if ( stat == null )
+ {
+ // the thread client has begin deleted the
children
+ threadDeleted = true;
--- End diff --
The point is that judge the new thread is running at the loop that is
deleting children:
```ZKPaths.java``` , 341 line
```
for ( String child : children )
{
String fullPath = makePath(path, child);
deleteChildren(zookeeper, fullPath, true);
}
```
and then, the main thread is try to delete some child that is still not
deleted by the new thread. If the main thread delete child successfully, the
new thread should not throw `NoNodeException`, but the old version will throw
NoNodeException and cause the remaining children are not deleted, that's the
bug situation.
So, it's unnecessary to checkExists() after that `threadDeleted` is true. I
just want the main thread delete a child successfully, when the new thread is
deleting children.
---