Java Thread Future exceptionallyCompletedFuture( final Throwable e)

Here you can find the source of exceptionallyCompletedFuture( final Throwable e)

Description

Creates a CompletableFuture which is completed exceptionally with the given Exception.

License

Apache License

Parameter

Parameter Description
e exception for the future
T the type of the value of the success case

Return

future

Declaration

public static <T> CompletableFuture<T> exceptionallyCompletedFuture(
        final Throwable e) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.concurrent.*;

public class Main {
    /**//from w  ww. j ava2 s.c o  m
     * Creates a {@link CompletableFuture} which is completed exceptionally with the given Exception.
     * Alias of {@link #failed(Throwable)}.
     *
     * {@include.example io.sphere.sdk.utils.CompletableFutureUtilsTest#testFailed()}
     *
     * @param e exception for the future
     * @param <T> the type of the value of the success case
     * @return future
     */
    public static <T> CompletableFuture<T> exceptionallyCompletedFuture(
            final Throwable e) {
        return failed(e);
    }

    /**
     * Creates a {@link CompletableFuture} which is completed exceptionally with the given Exception.
     *
     * {@include.example io.sphere.sdk.utils.CompletableFutureUtilsTest#testFailed()}
     *
     * @param e exception for the future
     * @param <T> the type of the value of the success case
     * @return future
     */
    public static <T> CompletableFuture<T> failed(final Throwable e) {
        final CompletableFuture<T> future = new CompletableFuture<>();
        future.completeExceptionally(e);
        return future;
    }
}

Related

  1. cancelScheduledFuture(ScheduledFuture scheduledFuture)
  2. checkTimeThresholds(long expectedMin, long expectedMax, long expectedOverhead, long start, Map> responses)
  3. commit(Object tx)
  4. convertFuture(Future future)
  5. createFuture()
  6. exceptionallyCompletedFuture(final Throwable t)
  7. getAll(List> futures)
  8. getAll(List> futures)
  9. getAllDone(Collection futures)