From 106422e55ab17fa1b6ab62172559e08cc8de6a5a Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sun, 16 Jun 2024 13:18:48 +0800 Subject: [PATCH] WIP --- .../java/io/foldright/cffu/CompletableFutureUtils.java | 10 +++++----- .../io/foldright/cffu/CompletableFutureUtilsTest.java | 2 +- 2 files changed, 6 insertions(+), 6 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 bf56cc6b..9ff2a882 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -221,7 +221,7 @@ public static CompletableFuture> mSupplyFastFailAsync( @SafeVarargs public static CompletableFuture> mSupplyMostSuccessAsync( @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier... suppliers) { - return mSupplyMostSuccessAsync(AsyncPoolHolder.ASYNC_POOL, timeout, unit, valueIfNotSuccess, suppliers); + return mSupplyMostSuccessAsync(valueIfNotSuccess, AsyncPoolHolder.ASYNC_POOL, timeout, unit, suppliers); } /** @@ -233,20 +233,20 @@ public static CompletableFuture> mSupplyMostSuccessAsync( * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * + * @param the suppliers' return type + * @param valueIfNotSuccess the value to return if not completed successfully * @param executor the executor to use for asynchronous execution * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter - * @param valueIfNotSuccess the value to return if not completed successfully * @param suppliers the suppliers returning the value to be used to complete the returned CompletableFuture - * @param the suppliers' return type * @return the new CompletableFuture * @see #mostResultsOfSuccess(Executor, long, TimeUnit, Object, CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ @SafeVarargs public static CompletableFuture> mSupplyMostSuccessAsync( - Executor executor, long timeout, TimeUnit unit, - @Nullable T valueIfNotSuccess, Supplier... suppliers) { + @Nullable T valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, + Supplier... suppliers) { requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); requireArrayAndEleNonNull("supplier", suppliers); diff --git a/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java b/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java index 29994cee..572d5235 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java @@ -75,7 +75,7 @@ void test_mSupply() throws Exception { mSupplyFastFailAsync(supplier, supplier), mSupplyFastFailAsync(executorService, supplier, supplier), mSupplyMostSuccessAsync(anotherN, 500, TimeUnit.MILLISECONDS, supplier, supplier), - mSupplyMostSuccessAsync(executorService, 500, TimeUnit.MILLISECONDS, anotherN, supplier, supplier), + mSupplyMostSuccessAsync(anotherN, executorService, 500, TimeUnit.MILLISECONDS, supplier, supplier), }; assertTrue(System.currentTimeMillis() - tick < 50);