From a0c1f9e4720b2885a38a637acd4c7d68b483ab7f Mon Sep 17 00:00:00 2001 From: huhaosumail <995483610@qq.com> Date: Mon, 24 Jun 2024 11:36:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=20`thenM*`=20methods:=20should=20use=20`f?= =?UTF-8?q?=5FtoCf`=20instead=20of=20`toNonMinCf`=20to=20keep=20the=20min-?= =?UTF-8?q?stage=20same=20as=20input=20cf=20=F0=9F=90=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cffu/CompletableFutureUtils.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) 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 314bf6e3..6a782572 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -1557,7 +1557,7 @@ public static CompletableFuture> 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))); } /** @@ -1611,7 +1611,7 @@ public static CompletableFuture> 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) )); } @@ -1650,7 +1650,7 @@ public static CompletableFuture> 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 CompletableFuture[] wrapFunctions( @@ -1692,7 +1692,7 @@ public static CompletableFuture 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))); } /** @@ -1729,7 +1729,7 @@ public static CompletableFuture 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 CompletableFuture[] wrapConsumers(Executor executor, T v, Consumer[] actions) { @@ -1776,37 +1776,37 @@ public static CompletableFuture 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 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 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 thenMRunAsync(CompletionStage cf, Runnable... actions) { - return thenMRunAsync(cf, AsyncPoolHolder.ASYNC_POOL, actions); + public static CompletableFuture 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