Skip to content

Commit

Permalink
refactor: add missing requireNonNull(exceptionType) of catching*
Browse files Browse the repository at this point in the history
…methods
  • Loading branch information
oldratlee committed Jul 28, 2024
1 parent 5c12e98 commit 1771585
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3574,6 +3574,7 @@ public static CompletableFuture<Void> runAfterEitherSuccessAsync(
public static <T, X extends Throwable, C extends CompletionStage<? super T>>
C catching(C cfThis, Class<X> exceptionType, Function<? super X, ? extends T> 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()))
Expand Down Expand Up @@ -3616,6 +3617,7 @@ C catchingAsync(C cfThis, Class<X> exceptionType, Function<? super X, ? extends
public static <T, X extends Throwable, C extends CompletionStage<? super T>>
C catchingAsync(C cfThis, Class<X> exceptionType, Function<? super X, ? extends T> fallback, Executor executor) {
requireNonNull(cfThis, "cfThis is null");
requireNonNull(exceptionType, "exceptionType is null");
requireNonNull(fallback, "fallback is null");
requireNonNull(executor, "executor is null");

Expand Down Expand Up @@ -3872,7 +3874,9 @@ private static void completeCf(CompletableFuture<Object> cf, Object value, @Null
public static <T, X extends Throwable, C extends CompletionStage<? super T>>
C catchingCompose(C cfThis, Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> 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);
Expand Down Expand Up @@ -3913,8 +3917,10 @@ public static <T, X extends Throwable, C extends CompletionStage<? super T>> C c
C cfThis, Class<X> exceptionType,
Function<? super X, ? extends CompletionStage<T>> 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);
Expand Down Expand Up @@ -4412,7 +4418,7 @@ public static <U> CompletableFuture<U> newIncompleteFuture(CompletableFuture<?>
// endregion
// endregion
////////////////////////////////////////////////////////////////////////////////
// region# Util Methods(static methods)
// region# Convenient Util Methods
//
// - toCompletableFutureArray: CompletionStage[](including Cffu) -> CF[]
// - completableFutureListToArray: List<CF> -> CF[]
Expand Down

0 comments on commit 1771585

Please sign in to comment.