/** * Returns a {@code CheckedFuture} which has an exception set immediately upon construction. * * <p>The returned {@code Future} can't be cancelled, and its {@code isDone()} method always * returns {@code true}. Calling {@code get()} will immediately throw the provided {@code * Exception} wrapped in an {@code ExecutionException}, and calling {@code checkedGet()} will * throw the provided exception itself. * * @deprecated {@link CheckedFuture} cannot properly support the chained operations that are the * primary goal of {@link ListenableFuture}. {@code CheckedFuture} also encourages users to * rethrow exceptions from one thread in another thread, producing misleading stack traces. * Additionally, it has a surprising policy about which exceptions to map and which to leave * untouched. Guava users who want a {@code CheckedFuture} can fork the classes for their own * use, possibly specializing them to the particular exception type they use. We recommend * that most people use {@code ListenableFuture} and perform any exception wrapping * themselves. This method is scheduled for removal from Guava in February 2018. */ @Deprecated @GwtIncompatible // TODO public static <V, X extends Exception> CheckedFuture<V, X> immediateFailedCheckedFuture( X exception) { checkNotNull(exception); return new ImmediateFailedCheckedFuture<V, X>(exception); }
/** * Returns a {@code CheckedFuture} which has an exception set immediately upon construction. * * <p>The returned {@code Future} can't be cancelled, and its {@code isDone()} method always * returns {@code true}. Calling {@code get()} will immediately throw the provided {@code * Exception} wrapped in an {@code ExecutionException}, and calling {@code checkedGet()} will * throw the provided exception itself. */ @GwtIncompatible // TODO public static <V, X extends Exception> CheckedFuture<V, X> immediateFailedCheckedFuture(X exception) { checkNotNull(exception); return new ImmediateFailedCheckedFuture<V, X>(exception); }
/** * Returns a {@code CheckedFuture} which has an exception set immediately upon construction. * * <p>The returned {@code Future} can't be cancelled, and its {@code isDone()} method always * returns {@code true}. Calling {@code get()} will immediately throw the provided {@code * Exception} wrapped in an {@code ExecutionException}, and calling {@code checkedGet()} will * throw the provided exception itself. */ @GwtIncompatible // TODO public static <V, X extends Exception> CheckedFuture<V, X> immediateFailedCheckedFuture( X exception) { checkNotNull(exception); return new ImmediateFailedCheckedFuture<V, X>(exception); }
/** * Returns a {@code CheckedFuture} which has an exception set immediately upon construction. * * <p>The returned {@code Future} can't be cancelled, and its {@code isDone()} method always * returns {@code true}. Calling {@code get()} will immediately throw the provided {@code * Exception} wrapped in an {@code ExecutionException}, and calling {@code checkedGet()} will * throw the provided exception itself. * * @deprecated {@link CheckedFuture} cannot properly support the chained operations that are the * primary goal of {@link ListenableFuture}. {@code CheckedFuture} also encourages users to * rethrow exceptions from one thread in another thread, producing misleading stack traces. * Additionally, it has a surprising policy about which exceptions to map and which to leave * untouched. Guava users who want a {@code CheckedFuture} can fork the classes for their own * use, possibly specializing them to the particular exception type they use. We recommend * that most people use {@code ListenableFuture} and perform any exception wrapping * themselves. This method is scheduled for removal from Guava in April 2018. */ // TODO(b/72241500): Remove by 2018-04 @Deprecated @GwtIncompatible // TODO public static <V, X extends Exception> CheckedFuture<V, X> immediateFailedCheckedFuture( X exception) { checkNotNull(exception); return new ImmediateFailedCheckedFuture<>(exception); }