org.zalando.riptide.capture.Completion Maven / Gradle / Ivy
package org.zalando.riptide.capture;
import lombok.SneakyThrows;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
public final class Completion {
Completion() {
// package private so we can trick code coverage
}
/**
* Joins the given {@link CompletableFuture future} by calling {@link CompletableFuture#join()}. If the given
* future was completed exceptionally, this method will throw the cause of that {@link CompletionException}.
*
* @see CompletableFuture#join()
* @see CompletionException#getCause()
* @param future the given future
* @param generic future result type
* @return the result of the given future
* @throws RuntimeException the exception if the given future was completed exceptionally
*/
@SneakyThrows
public static T join(final CompletableFuture future) {
try {
return future.join();
} catch (final CompletionException e) {
throw e.getCause();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy