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 3f377bff..ccb375f9 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -3574,6 +3574,7 @@ public static CompletableFuture runAfterEitherSuccessAsync( public static > C catching(C cfThis, Class exceptionType, Function fallback) { requireNonNull(cfThis, "cfThis is null"); + requireNonNull(exceptionType, "exceptionType is null"); requireNonNull(fallback, "fallback is null"); return (C) cfThis.handle((v, ex) -> (ex == null || !exceptionType.isAssignableFrom(ex.getClass())) @@ -3616,6 +3617,7 @@ C catchingAsync(C cfThis, Class exceptionType, Function> C catchingAsync(C cfThis, Class exceptionType, Function fallback, Executor executor) { requireNonNull(cfThis, "cfThis is null"); + requireNonNull(exceptionType, "exceptionType is null"); requireNonNull(fallback, "fallback is null"); requireNonNull(executor, "executor is null"); @@ -3872,7 +3874,9 @@ private static void completeCf(CompletableFuture cf, Object value, @Null public static > C catchingCompose(C cfThis, Class exceptionType, Function> fallback) { requireNonNull(cfThis, "cfThis is null"); + requireNonNull(exceptionType, "exceptionType is null"); requireNonNull(fallback, "fallback is null"); + return (C) cfThis.handle((v, ex) -> (ex == null || !exceptionType.isAssignableFrom(ex.getClass())) ? cfThis : fallback.apply((X) ex) ).thenCompose(x -> x); @@ -3913,8 +3917,10 @@ public static > C c C cfThis, Class exceptionType, Function> fallback, Executor executor) { requireNonNull(cfThis, "cfThis is null"); + requireNonNull(exceptionType, "exceptionType is null"); requireNonNull(fallback, "fallback is null"); requireNonNull(executor, "executor is null"); + return (C) cfThis.handle((v, ex) -> (ex == null || !exceptionType.isAssignableFrom(ex.getClass())) ? cfThis : cfThis.handleAsync((v1, ex1) -> fallback.apply((X) ex1), executor).thenCompose(x -> x) ).thenCompose(x -> x); @@ -4412,7 +4418,7 @@ public static CompletableFuture newIncompleteFuture(CompletableFuture // endregion // endregion //////////////////////////////////////////////////////////////////////////////// - // region# Util Methods(static methods) + // region# Convenient Util Methods // // - toCompletableFutureArray: CompletionStage[](including Cffu) -> CF[] // - completableFutureListToArray: List -> CF[]