Java9ContextAwareFuture extends AbstractContextAwareFuture<T> { @Override public CompletionStage<T> minimalCompletionStage() { return new Java9ContextAwareMinimalStage<>(this); } Java9ContextAwareFuture(RequestContext requestContext); @Override CompletableFuture<U> thenApply(Function<? super T, ? extends U> fn); @Override CompletableFuture<U> thenApplyAsync(Function<? super T, ? extends U> fn); @Override CompletableFuture<U> thenApplyAsync(Function<? super T, ? extends U> fn, Executor executor); @Override CompletableFuture<Void> thenAccept(Consumer<? super T> action); @Override CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action); @Override CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor); @Override CompletableFuture<Void> thenRun(Runnable action); @Override CompletableFuture<Void> thenRunAsync(Runnable action); @Override CompletableFuture<Void> thenRunAsync(Runnable action, Executor executor); @Override CompletableFuture<V> thenCombine(CompletionStage<? extends U> other,
                                                   BiFunction<? super T, ? super U, ? extends V> fn); @Override CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other,
                                                        BiFunction<? super T, ? super U, ? extends V> fn); @Override CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other,
                                                        BiFunction<? super T, ? super U, ? extends V> fn,
                                                        Executor executor); @Override CompletableFuture<Void> thenAcceptBoth(CompletionStage<? extends U> other,
                                                      BiConsumer<? super T, ? super U> action); @Override CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                           BiConsumer<? super T, ? super U> action); @Override CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                           BiConsumer<? super T, ? super U> action,
                                                           Executor executor); @Override CompletableFuture<Void> runAfterBoth(CompletionStage<?> other, Runnable action); @Override CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action); @Override CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other,
                                                     Runnable action,
                                                     Executor executor); @Override CompletableFuture<U> applyToEither(CompletionStage<? extends T> other,
                                                  Function<? super T, U> fn); @Override CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other,
                                                       Function<? super T, U> fn); @Override CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other,
                                                       Function<? super T, U> fn,
                                                       Executor executor); @Override CompletableFuture<Void> acceptEither(CompletionStage<? extends T> other,
                                                Consumer<? super T> action); @Override CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other,
                                                     Consumer<? super T> action); @Override CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other,
                                                     Consumer<? super T> action,
                                                     Executor executor); @Override CompletableFuture<Void> runAfterEither(CompletionStage<?> other, Runnable action); @Override CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action); @Override CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other,
                                                       Runnable action,
                                                       Executor executor); @Override CompletableFuture<U> thenCompose(Function<? super T, ? extends CompletionStage<U>> fn); @Override CompletableFuture<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn); @Override CompletableFuture<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn,
                                                     Executor executor); @Override CompletableFuture<T> whenComplete(BiConsumer<? super T, ? super Throwable> action); @Override CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action); @Override CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action,
                                                  Executor executor); @Override CompletableFuture<U> handle(BiFunction<? super T, Throwable, ? extends U> fn); @Override CompletableFuture<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn); @Override CompletableFuture<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn,
                                                Executor executor); @Override CompletableFuture<T> exceptionally(Function<Throwable, ? extends T> fn); @Override CompletableFuture<U> newIncompleteFuture(); @Override CompletionStage<T> minimalCompletionStage(); @Override CompletableFuture<T> completeAsync(Supplier<? extends T> supplier); @Override CompletableFuture<T> completeAsync(Supplier<? extends T> supplier, Executor executor);  }
@Test void minimalCompletionStageUsingToCompletableFutureMutable() throws Exception { final RequestContext context = ServiceRequestContext.builder(HttpRequest.of(HttpMethod.GET, "/")).build(); final CompletableFuture<Integer> originalFuture = new CompletableFuture<>(); final CompletableFuture<Integer> contextAwareFuture = context.makeContextAware(originalFuture); final CompletionStage<Integer> completionStage = contextAwareFuture.minimalCompletionStage(); assertThat(contextAwareFuture.complete(1)).isTrue(); assertThat(contextAwareFuture.join()).isEqualTo(1); assertThat(contextAwareFuture.getNow(null)).isEqualTo(1); assertThat(contextAwareFuture.get()).isEqualTo(1); assertThat(completionStage.toCompletableFuture().get()).isEqualTo(1); }