Skip to content

Commit

Permalink
fix thenM* methods: should use f_toCf instead of toNonMinCf to …
Browse files Browse the repository at this point in the history
…keep the min-stage same as input cf 🐞
  • Loading branch information
oldratlee committed Jun 24, 2024
1 parent bcba60b commit 4892aa9
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ public static <T, U> CompletableFuture<List<U>> thenMApplyFastFailAsync(
requireNonNull(executor, "executor is null");
requireArrayAndEleNonNull("fn", fns);

return toNonMinCf(cf).thenCompose(v -> allResultsOfFastFail(wrapFunctions(executor, v, fns)));
return f_toCf(cf).thenCompose(v -> allResultsOfFastFail(wrapFunctions(executor, v, fns)));
}

/**
Expand Down Expand Up @@ -1620,7 +1620,7 @@ public static <T, U> CompletableFuture<List<U>> thenMApplyMostSuccessAsync(
requireNonNull(unit, "unit is null");
requireArrayAndEleNonNull("fn", fns);

return toNonMinCf(cf).thenCompose(v -> mostResultsOfSuccess(
return f_toCf(cf).thenCompose(v -> mostResultsOfSuccess(
valueIfNotSuccess, executor, timeout, unit, wrapFunctions(executor, v, fns)
));
}
Expand Down Expand Up @@ -1659,7 +1659,7 @@ public static <T, U> CompletableFuture<List<U>> thenMApplyAsync(
requireNonNull(executor, "executor is null");
requireArrayAndEleNonNull("fn", fns);

return toNonMinCf(cf).thenCompose(v -> allResultsOf(wrapFunctions(executor, v, fns)));
return f_toCf(cf).thenCompose(v -> allResultsOf(wrapFunctions(executor, v, fns)));
}

private static <T, U> CompletableFuture<U>[] wrapFunctions(
Expand Down Expand Up @@ -1701,7 +1701,7 @@ public static <T> CompletableFuture<Void> thenMAcceptAsync(
requireNonNull(executor, "executor is null");
requireArrayAndEleNonNull("action", actions);

return toNonMinCf(cf).thenCompose(v -> CompletableFuture.allOf(wrapConsumers(executor, v, actions)));
return f_toCf(cf).thenCompose(v -> CompletableFuture.allOf(wrapConsumers(executor, v, actions)));
}

/**
Expand Down Expand Up @@ -1738,7 +1738,7 @@ public static <T> CompletableFuture<Void> thenMAcceptFastFailAsync(
requireNonNull(executor, "executor is null");
requireArrayAndEleNonNull("action", actions);

return toNonMinCf(cf).thenCompose(v -> allOfFastFail(wrapConsumers(executor, v, actions)));
return f_toCf(cf).thenCompose(v -> allOfFastFail(wrapConsumers(executor, v, actions)));
}

private static <T> CompletableFuture<Void>[] wrapConsumers(Executor executor, T v, Consumer<? super T>[] actions) {
Expand Down Expand Up @@ -1785,37 +1785,37 @@ public static CompletableFuture<Void> thenMRunFastFailAsync(
requireNonNull(executor, "executor is null");
requireArrayAndEleNonNull("action", actions);

return toNonMinCf(cf).thenCompose(unused -> allOfFastFail(wrapRunnables(executor, actions)));
return f_toCf(cf).thenCompose(unused -> allOfFastFail(wrapRunnables(executor, actions)));
}

/**
* Returns a new CompletableFuture that, when the given stage completes normally,
* executes the given actions using the given Executor.
* executes the given actions using the CompletableFuture's default asynchronous execution facility.
*
* @param actions the actions to perform before completing the returned CompletableFuture
* @return the new CompletableFuture
* @see CompletableFuture#thenRunAsync(Runnable, Executor)
* @see CompletableFuture#thenRunAsync(Runnable)
* @see #allOf(CompletionStage[])
*/
public static CompletableFuture<Void> thenMRunAsync(CompletionStage<?> cf, Executor executor, Runnable... actions) {
requireNonNull(cf, "cf is null");
requireNonNull(executor, "executor is null");
requireArrayAndEleNonNull("action", actions);

return toNonMinCf(cf).thenCompose(unused -> CompletableFuture.allOf(wrapRunnables(executor, actions)));
public static CompletableFuture<Void> thenMRunAsync(CompletionStage<?> cf, Runnable... actions) {
return thenMRunAsync(cf, AsyncPoolHolder.ASYNC_POOL, actions);
}

/**
* Returns a new CompletableFuture that, when the given stage completes normally,
* executes the given actions using the CompletableFuture's default asynchronous execution facility.
* executes the given actions using the given Executor.
*
* @param actions the actions to perform before completing the returned CompletableFuture
* @return the new CompletableFuture
* @see CompletableFuture#thenRunAsync(Runnable)
* @see CompletableFuture#thenRunAsync(Runnable, Executor)
* @see #allOf(CompletionStage[])
*/
public static CompletableFuture<Void> thenMRunAsync(CompletionStage<?> cf, Runnable... actions) {
return thenMRunAsync(cf, AsyncPoolHolder.ASYNC_POOL, actions);
public static CompletableFuture<Void> thenMRunAsync(CompletionStage<?> cf, Executor executor, Runnable... actions) {
requireNonNull(cf, "cf is null");
requireNonNull(executor, "executor is null");
requireArrayAndEleNonNull("action", actions);

return f_toCf(cf).thenCompose(unused -> CompletableFuture.allOf(wrapRunnables(executor, actions)));
}

// endregion
Expand Down

0 comments on commit 4892aa9

Please sign in to comment.