public static CompletableFuture<Void> joinFutures(Collection<CompletableFuture<?>> futures) {
    CompletableFuture<Void> result = CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
    // fail fast on exceptions
    for (CompletableFuture<?> f : futures) {
      f.whenComplete((res, ex) -> {
        if (ex != null) {
          result.completeExceptionally(ex);
          futures.forEach(other -> other.cancel(true));
        }
      });
    }
    return result;
  }
Returns a future that completes successfully when all {@code futures} complete, or fails immediately when the first
one fails.
planetiler-core/src/main/java/com/onthegomap/planetiler/worker/Worker.java