Here you can find the source of transferResult(final CompletionStage
public static <T> void transferResult(final CompletionStage<T> source, final CompletableFuture<T> target)
//package com.java2s; //License from project: Apache License import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; public class Main { public static <T> void transferResult(final CompletionStage<T> source, final CompletableFuture<T> target) { source.whenComplete((result, throwable) -> { final boolean isSuccessful = throwable == null; if (isSuccessful) { target.complete(result); } else { target.completeExceptionally(throwable); }/* www . ja va 2 s . c om*/ }); } }