private static <U> KafkaCompletableFuture<U> toKafkaCompletableFuture(CompletableFuture<U> completableFuture) {
        if (completableFuture instanceof KafkaCompletableFuture) {
            return (KafkaCompletableFuture<U>) completableFuture;
        } else {
            final KafkaCompletableFuture<U> result = new KafkaCompletableFuture<>();
            completableFuture.whenComplete((x, y) -> {
                if (y != null) {
                    result.kafkaCompleteExceptionally(y);
                } else {
                    result.kafkaComplete(x);
                }
            });
            return result;
        }
    }
Returns a new KafkaFuture that, when this future completes normally, is executed with this
futures's result as the argument to the supplied function.
clients/src/main/java/org/apache/kafka/common/internals/KafkaFutureImpl.java