poorbarcode commented on code in PR #17524:
URL: https://github.com/apache/pulsar/pull/17524#discussion_r1447300798


##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java:
##########
@@ -69,6 +70,32 @@ public static <T> CompletableFuture<List<T>> 
waitForAll(Stream<CompletableFuture
                 })));
     }
 
+    /**
+     * Make {@param dest} completed as {@param src}.

Review Comment:
   Renamed to `completeAfter`,  and modified the description.



##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java:
##########
@@ -69,6 +70,32 @@ public static <T> CompletableFuture<List<T>> 
waitForAll(Stream<CompletableFuture
                 })));
     }
 
+    /**
+     * Make {@param dest} completed as {@param src}.
+     */
+    public static <T> void completeAs(final CompletableFuture<T> dest, 
CompletableFuture<T> src){
+        src.whenComplete((v, ex) -> {
+            if (ex != null){
+                dest.completeExceptionally(ex);
+            } else {
+                dest.complete(v);
+            }
+        });
+    }
+
+    /**
+     * Make {@param dest} completed as {@param src}.
+     */
+    public static <T> void completeAs(final CompletableFuture<Void> dest, 
CompletableFuture<T>...src){

Review Comment:
   Renamed to `completeAfter`,  and modified the description.



##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java:
##########
@@ -69,6 +70,32 @@ public static <T> CompletableFuture<List<T>> 
waitForAll(Stream<CompletableFuture
                 })));
     }
 
+    /**
+     * Make {@param dest} completed as {@param src}.
+     */
+    public static <T> void completeAs(final CompletableFuture<T> dest, 
CompletableFuture<T> src){
+        src.whenComplete((v, ex) -> {
+            if (ex != null){
+                dest.completeExceptionally(ex);
+            } else {
+                dest.complete(v);
+            }
+        });
+    }
+
+    /**
+     * Make {@param dest} completed as {@param src}.
+     */
+    public static <T> void completeAs(final CompletableFuture<Void> dest, 
CompletableFuture<T>...src){

Review Comment:
   Renamed to `completeAfterAll`,  and modified the description.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to