code: public static <T> void completeAfter(Supplier<CompletableFuture<? extends T>> futureSupplier, CompletableFuture<T> toComplete) {
          Preconditions.checkArgument(!toComplete.isDone(), "toComplete is already completed.");
          try {
              CompletableFuture<? extends T> f = futureSupplier.get();
  
              // Async termination.
              f.thenAccept(toComplete::complete);
              Futures.exceptionListener(f, toComplete::completeExceptionally);
          } catch (Throwable ex) {
              // Synchronous termination.
              toComplete.completeExceptionally(ex);
              throw ex;
          }
      }
docs: Given a Supplier returning a Future, completes another future either with the result of the first future, in case
  of normal completion, or exceptionally with the exception of the first future.
  
  @param futureSupplier A Supplier returning a Future to listen to.
  @param toComplete     A CompletableFuture that has not yet been completed, which will be completed with the result
  of the Future from futureSupplier.
  @param <T>            Return type of Future.