@Test public void cancelShouldCompleteTheFuture() throws Exception { responseFuture.cancel(true); assertTrue(responseFuture.isDone()); assertTrue(responseFuture.isCancelled()); try { responseFuture.get(); fail("Should have thrown exception"); } catch (CancellationException e) { assertNotNull(e); } }
@Override public boolean cancel(boolean mayInterruptIfRunning) { if (isCancelled() || isDone() || isCompletedExceptionally()) { return false; } requestEventBus.triggerEvent(Event.ERROR, requestContext, new CancellationException()); super.cancel(mayInterruptIfRunning); return true; }
ResponseFuture extends CompletableFuture<HttpResponse<T>> { @Override public boolean cancel(boolean mayInterruptIfRunning) { if (isCancelled() || isDone() || isCompletedExceptionally()) { return false; } requestEventBus.triggerEvent(Event.ERROR, requestContext, new CancellationException()); super.cancel(mayInterruptIfRunning); return true; } }
ResponseFuture extends CompletableFuture<HttpResponse<T>> { @Override public boolean cancel(boolean mayInterruptIfRunning) { if (isCancelled() || isDone() || isCompletedExceptionally()) { return false; } requestEventBus.triggerEvent(Event.ERROR, requestContext, new CancellationException()); super.cancel(mayInterruptIfRunning); return true; } ResponseFuture(RequestEventBus requestEventBus, HttpRequestContext requestContext, Executor callbackExecutor); }
ResponseFuture extends CompletableFuture<HttpResponse<T>> { @Override public boolean cancel(boolean mayInterruptIfRunning) { if (isCancelled() || isDone() || isCompletedExceptionally()) { return false; } requestEventBus.triggerEvent(Event.ERROR, requestContext, new CancellationException()); super.cancel(mayInterruptIfRunning); return true; } ResponseFuture(RequestEventBus requestEventBus, HttpRequestContext requestContext, Executor callbackExecutor); @Override boolean cancel(boolean mayInterruptIfRunning); static CompletableFuture<HttpResponse<T>> error(Throwable error); }
ResponseFuture extends CompletableFuture<HttpResponse<T>> { @Override public boolean cancel(boolean mayInterruptIfRunning) { if (isCancelled() || isDone() || isCompletedExceptionally()) { return false; } requestEventBus.triggerEvent(Event.ERROR, requestContext, new CancellationException()); super.cancel(mayInterruptIfRunning); return true; } ResponseFuture(RequestEventBus requestEventBus, HttpRequestContext requestContext, Executor callbackExecutor); @Override boolean cancel(boolean mayInterruptIfRunning); static CompletableFuture<HttpResponse<T>> error(Throwable error);  }