ThriftListenableFuture extends AbstractFuture<T> implements AsyncMethodCallback<T> { public static <T> ThriftListenableFuture<T> exceptionallyCompletedFuture(Throwable cause) { requireNonNull(cause, "cause"); final ThriftListenableFuture<T> future = new ThriftListenableFuture<>(); future.onError(cause instanceof Exception ? (Exception) cause : new CompletionException(cause)); return future; }  static ThriftListenableFuture<T> completedFuture(@Nullable T value); static ThriftListenableFuture<T> exceptionallyCompletedFuture(Throwable cause); @Override void onComplete(@Nullable T value); @Override void onError(Exception cause);  }
@Test void testFailedListenableFuture() throws Exception { assumeUnshadedGuava(); final ThriftListenableFuture<String> future = exceptionallyCompletedFuture(new IllegalStateException()); assertThatThrownBy(future::get).hasCauseInstanceOf(IllegalStateException.class); }