DefaultPromise extends AbstractFuture<V> implements Promise<V> { @Override public boolean cancel(boolean mayInterruptIfRunning) { Object result = this.result; if (isDone0(result) || result == UNCANCELLABLE) { return false; } synchronized (this) { result = this.result; if (isDone0(result) || result == UNCANCELLABLE) { return false; } this.result = CANCELLATION_CAUSE_HOLDER; if (hasWaiters()) { notifyAll(); } } notifyListeners(); return true; } DefaultPromise(EventExecutor executor); protected  DefaultPromise(); @Override boolean isCancelled(); @Override boolean isCancellable(); @Override boolean isDone(); @Override boolean isSuccess(); @Override Throwable cause(); @Override Promise<V> addListener(GenericFutureListener<? extends Future<? super V>> listener); @Override Promise<V> addListeners(GenericFutureListener<? extends Future<? super V>>... listeners); @Override Promise<V> removeListener(GenericFutureListener<? extends Future<? super V>> listener); @Override Promise<V> removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners); @Override Promise<V> sync(); @Override Promise<V> syncUninterruptibly(); @Override Promise<V> await(); @Override boolean await(long timeout, TimeUnit unit); @Override boolean await(long timeoutMillis); @Override Promise<V> awaitUninterruptibly(); @Override boolean awaitUninterruptibly(long timeout, TimeUnit unit); @Override boolean awaitUninterruptibly(long timeoutMillis); @Override Promise<V> setSuccess(V result); @Override boolean trySuccess(V result); @Override Promise<V> setFailure(Throwable cause); @Override boolean tryFailure(Throwable cause); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean setUncancellable(); @Override @SuppressWarnings("unchecked") V getNow(); @Override String toString();  }
@Test(expected = CancellationException.class) public void testCancellationExceptionIsThrownWhenBlockingGet() throws InterruptedException, ExecutionException { final Promise<Void> promise = new DefaultPromise<Void>(ImmediateEventExecutor.INSTANCE); promise.cancel(false); promise.get(); }
@Test(expected = CancellationException.class) public void testCancellationExceptionIsThrownWhenBlockingGetWithTimeout() throws InterruptedException, ExecutionException, TimeoutException { final Promise<Void> promise = new DefaultPromise<Void>(ImmediateEventExecutor.INSTANCE); promise.cancel(false); promise.get(1, TimeUnit.SECONDS); }