You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ijuma (via GitHub)" <gi...@apache.org> on 2023/02/03 00:15:00 UTC

[GitHub] [kafka] ijuma commented on a diff in pull request #13169: KAFKA-14658: Do not open broker ports until we are ready to accept traffic

ijuma commented on code in PR #13169:
URL: https://github.com/apache/kafka/pull/13169#discussion_r1095220913


##########
server-common/src/main/java/org/apache/kafka/server/util/FutureUtils.java:
##########
@@ -66,4 +67,27 @@ public static <T> T waitWithLogging(
             throw new RuntimeException("Received a fatal error while waiting for " + action, t);
         }
     }
+
+    /**
+     * Complete a given destination future when a source future is completed.
+     *
+     * @param sourceFuture          The future to trigger off of.
+     * @param destinationFuture     The future to complete when the source future is completed.
+     * @param <T>                   The destination future type.
+     */
+    public static <T> void chainFuture(
+        CompletableFuture<? extends T> sourceFuture,
+        CompletableFuture<T> destinationFuture
+    ) {
+        sourceFuture.whenComplete(new BiConsumer<T, Throwable>() {
+            @Override
+            public void accept(T val, Throwable throwable) {

Review Comment:
   Nit: you can use a lambda instead of an anonymous inner class.



-- 
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: jira-unsubscribe@kafka.apache.org

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