You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by "tisonkun (via GitHub)" <gi...@apache.org> on 2023/04/02 04:07:21 UTC

[GitHub] [curator] tisonkun commented on a diff in pull request #453: CURATOR-665: ZKPaths.mkdirs should complete background on exception

tisonkun commented on code in PR #453:
URL: https://github.com/apache/curator/pull/453#discussion_r1155235873


##########
curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java:
##########
@@ -770,14 +790,24 @@ static <T> void backgroundCreateParentsThenNode(final CuratorFrameworkImpl clien
             @Override
             public void performBackgroundOperation(OperationAndData<T> dummy) throws Exception
             {
+                AtomicReference<CuratorEvent> event = new AtomicReference<>();
+                AsyncCallback.Create2Callback callback = new AsyncCallback.Create2Callback()
+                {
+                    @Override
+                    public void processResult(int rc, String path, Object ctx, String name, Stat stat)
+                    {
+                        event.set(createResponseEvent(client, rc, path, ctx, name, stat));
+                    }
+                };
                 try
                 {
-                    ZKPaths.mkdirs(client.getZooKeeper(), path, false, aclProvider, createParentsAsContainers);
+                    ZKPaths.mkdirs(client.getZooKeeper(), path, false, aclProvider, createParentsAsContainers, callback);
                 }
                 catch ( KeeperException e )
                 {
                     if ( !client.getZookeeperClient().getRetryPolicy().allowRetry(e) )
                     {
+                        client.processBackgroundOperation(mainOperationAndData, event.get());

Review Comment:
   @kezhuw Thanks for your insight!
   
   I checked that on exception, `stat` should be `null`, `ctx` we passed is `null`, and since we don't create sequential node here, `path == name`. So you're right that I can tidy the code a lot.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org