Skip to content

Commit

Permalink
chore(utils): Refactor FutureUtils with KIP-707
Browse files Browse the repository at this point in the history
  • Loading branch information
gquintana authored and fhussonnois committed Oct 14, 2021
1 parent 18edfdc commit 81b413b
Showing 1 changed file with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,12 @@

public class FutureUtils {

public static <T> CompletableFuture<T> toCompletableFuture(final KafkaFuture<T> listings) {
return CompletableFuture.supplyAsync(() -> {
try {
return listings.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
});
public static <T> CompletableFuture<T> toCompletableFuture(final KafkaFuture<T> future) {
return future.toCompletionStage().toCompletableFuture();
}

public static CompletableFuture<Void> toVoidCompletableFuture(final KafkaFuture<?> listings) {
return CompletableFuture.supplyAsync(() -> {
try {
listings.get();
return null;
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
});
public static CompletableFuture<Void> toVoidCompletableFuture(final KafkaFuture<?> future) {
return toCompletableFuture(future).thenApply(p -> null);
}

public static <T extends Change<T>> CompletableFuture<OperationResult<T>> makeCompletableFuture(
Expand Down

0 comments on commit 81b413b

Please sign in to comment.