/** * Get the value of a completed stage. * * @param stage a completed {@link CompletionStage}. * @return the value of the stage if it has one. * @throws IllegalStateException if the stage is not completed. * @throws java.util.concurrent.CompletionException if the future completed exceptionally. */ public static <T> T getCompleted(CompletionStage<T> stage) { CompletableFuture<T> future = stage.toCompletableFuture(); checkCompleted(future); return future.join(); }