public static <T> void chainFuture(
        CompletableFuture<? extends T> sourceFuture,
        CompletableFuture<T> destinationFuture
    ) {
        sourceFuture.whenComplete((BiConsumer<T, Throwable>) (val, throwable) -> {
            if (throwable != null) {
                destinationFuture.completeExceptionally(throwable);
            } else {
                destinationFuture.complete(val);
            }
        });
    }
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.
server-common/src/main/java/org/apache/kafka/server/util/FutureUtils.java