Skip to content

Commit

Permalink
Use new List#toArray method
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit committed Oct 3, 2023
1 parent 5220c26 commit 3c50ced
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.pivovarit.collectors;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -79,11 +78,10 @@ public Set<Characteristics> characteristics() {
}

private static <T> CompletableFuture<Stream<T>> combine(List<CompletableFuture<T>> futures) {
CompletableFuture<T>[] futuresArray = (CompletableFuture<T>[]) futures.toArray(new CompletableFuture[0]);
CompletableFuture<Stream<T>> combined = allOf(futuresArray)
.thenApply(__ -> Arrays.stream(futuresArray).map(CompletableFuture::join));
var combined = allOf(futures.toArray(CompletableFuture[]::new))
.thenApply(__ -> futures.stream().map(CompletableFuture::join));

for (CompletableFuture<?> f : futuresArray) {
for (CompletableFuture<?> f : futures) {
f.exceptionally(ex -> {
combined.completeExceptionally(ex);
return null;
Expand Down

0 comments on commit 3c50ced

Please sign in to comment.