@Test public void shouldRecoverTimeoutException() throws Exception { CompletableFuture<String> future = new CompletableFuture<>(); future.completeExceptionally(new TimeoutException()); String result = recover(future, (e) -> "fallback").toCompletableFuture() .get(1, TimeUnit.SECONDS); assertThat(result).isEqualTo("fallback"); }
public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler){ return completionStage.exceptionally(exceptionHandler); }
CompletionStageUtils { public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler){ return completionStage.exceptionally(exceptionHandler); } }
CompletionStageUtils { public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler){ return completionStage.exceptionally(exceptionHandler); } private  CompletionStageUtils(); }
CompletionStageUtils { public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler){ return completionStage.exceptionally(exceptionHandler); } private  CompletionStageUtils(); static CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler); static CompletionStage<T> recover(CompletionStage<T> completionStage, List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler); static CompletionStage<T> recover(CompletionStage<T> completionStage, Class<X> exceptionType, Function<Throwable, T> exceptionHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier,
        Function<Throwable, T> exceptionHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier, Class<X> exceptionType,
        Function<Throwable, T> exceptionHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier, List<Class<? extends Throwable>> exceptionTypes,
        Function<Throwable, T> exceptionHandler); static CompletionStage<T> recover(
        CompletionStage<T> completionStage, Predicate<T> resultPredicate,
        UnaryOperator<T> resultHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier, Predicate<T> resultPredicate,
        UnaryOperator<T> resultHandler); static Supplier<CompletionStage<R>> andThen(Supplier<CompletionStage<T>> completionStageSupplier,
        BiFunction<T, Throwable, R> handler); }
CompletionStageUtils { public static <T> CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler){ return completionStage.exceptionally(exceptionHandler); } private  CompletionStageUtils(); static CompletionStage<T> recover(CompletionStage<T> completionStage, Function<Throwable, T> exceptionHandler); static CompletionStage<T> recover(CompletionStage<T> completionStage, List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler); static CompletionStage<T> recover(CompletionStage<T> completionStage, Class<X> exceptionType, Function<Throwable, T> exceptionHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier,
        Function<Throwable, T> exceptionHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier, Class<X> exceptionType,
        Function<Throwable, T> exceptionHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier, List<Class<? extends Throwable>> exceptionTypes,
        Function<Throwable, T> exceptionHandler); static CompletionStage<T> recover(
        CompletionStage<T> completionStage, Predicate<T> resultPredicate,
        UnaryOperator<T> resultHandler); static Supplier<CompletionStage<T>> recover(
        Supplier<CompletionStage<T>> completionStageSupplier, Predicate<T> resultPredicate,
        UnaryOperator<T> resultHandler); static Supplier<CompletionStage<R>> andThen(Supplier<CompletionStage<T>> completionStageSupplier,
        BiFunction<T, Throwable, R> handler);  }