diff --git a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java index cbc18984..7a49a6a8 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -719,7 +719,8 @@ private static CompletableFuture f_mostSuccessTupleOf0( Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage[] stages) { // 1. MUST be non-minimal-stage CF instances in order to read results(`getSuccessNow`), otherwise UnsupportedOpException. // 2. SHOULD copy input cfs to avoid memory leaks, otherwise all input cfs would be retained until output cf completes. - final CompletableFuture[] cfArray = toNonMinCfCopyArray0(stages); + CompletableFuture[] cfArray = mapArray(stages, CompletableFuture[]::new, + s -> toNonMinCf0(s).exceptionally(v -> null)); return cffuCompleteOnTimeout(CompletableFuture.allOf(cfArray), null, timeout, unit, executorWhenTimeout) .handle((unused, ex) -> f_tupleOf0(f_mGetSuccessNow0(null, cfArray))); } @@ -946,7 +947,8 @@ private static CompletableFuture> mostSuccessResultsOf0( // 1. MUST be non-minimal-stage CF instances in order to read results(`getSuccessNow`), otherwise UnsupportedOpException. // 2. SHOULD copy input cfs to avoid memory leaks, otherwise all input cfs would be retained until output cf completes. - final CompletableFuture[] cfArray = toNonMinCfCopyArray0(cfs); + CompletableFuture[] cfArray = mapArray(cfs, CompletableFuture[]::new, + s -> LLCF.toNonMinCf0(s).exceptionally(v -> valueIfNotSuccess)); return cffuCompleteOnTimeout(CompletableFuture.allOf(cfArray), null, timeout, unit, executorWhenTimeout) .handle((unused, ex) -> arrayList(f_mGetSuccessNow0(valueIfNotSuccess, cfArray))); }