public static <L, R> CompletableFuture<Pair<L, R>> toFutureOfPair(
      Pair<CompletableFuture<L>, CompletableFuture<R>> pairOfFutures) {
    return CompletableFuture
        .allOf(pairOfFutures.getLeft(), pairOfFutures.getRight())
        .thenApply(v -> Pair.of(pairOfFutures.getLeft().join(), pairOfFutures.getRight().join()));
  }
Helper method to convert: {@code Pair<CompletableFuture<L>, CompletableFuture<R>>}
to:                       {@code CompletableFuture<Pair<L, R>>}

Returns a future that completes when both futures complete.
Returned future completes exceptionally if either of the futures complete exceptionally.
samza-core/src/main/java/org/apache/samza/util/FutureUtil.java