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
huhaosumail authored and oldratlee committed Jun 24, 2024
1 parent 5119a20 commit a0c1f9e
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,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 @@ -1611,7 +1611,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 @@ -1650,7 +1650,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 @@ -1692,7 +1692,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 @@ -1729,7 +1729,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 @@ -1776,37 +1776,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 a0c1f9e

Please sign in to comment.