in curator-framework/src/main/java/org/apache/curator/framework/imps/DeleteBuilderImpl.java [278:321]
private void pathInForeground(final String path, String unfixedPath) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("DeleteBuilderImpl-Foreground");
try {
RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<Void>() {
@Override
public Void call() throws Exception {
if (failBeforeNextDeleteForTesting) {
failBeforeNextDeleteForTesting = false;
throw new KeeperException.ConnectionLossException();
}
try {
client.getZooKeeper().delete(path, version);
} catch (KeeperException.NoNodeException e) {
if (!quietly) {
throw e;
}
} catch (KeeperException.NotEmptyException e) {
if (deletingChildrenIfNeeded) {
ZKPaths.deleteChildren(client.getZooKeeper(), path, true);
} else {
throw e;
}
}
if (failNextDeleteForTesting) {
failNextDeleteForTesting = false;
throw new KeeperException.ConnectionLossException();
}
return null;
}
});
} catch (Exception e) {
ThreadUtils.checkInterrupted(e);
// Only retry a guaranteed delete if it's a retryable error
if ((client.getZookeeperClient().getRetryPolicy().allowRetry(e) || (e instanceof InterruptedException))
&& guaranteed) {
client.getFailedDeleteManager().addFailedOperation(unfixedPath);
}
throw e;
}
trace.setPath(path).commit();
}