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