@Override public boolean isDone() { return isDone != 0 || isCancelled(); }
@Test public void testCancel() { AsyncHandler<?> asyncHandler = mock(AsyncHandler.class); NettyResponseFuture<?> nettyResponseFuture = new NettyResponseFuture<>(null, asyncHandler, null, 3, null, null, null); boolean result = nettyResponseFuture.cancel(false); verify(asyncHandler).onThrowable(anyObject()); assertTrue(result, "Cancel should return true if the Future was cancelled successfully"); assertTrue(nettyResponseFuture.isCancelled(), "isCancelled should return true for a cancelled Future"); }
@Test public void testCancelOnAlreadyCancelled() { AsyncHandler<?> asyncHandler = mock(AsyncHandler.class); NettyResponseFuture<?> nettyResponseFuture = new NettyResponseFuture<>(null, asyncHandler, null, 3, null, null, null); nettyResponseFuture.cancel(false); boolean result = nettyResponseFuture.cancel(false); assertFalse(result, "cancel should return false for an already cancelled Future"); assertTrue(nettyResponseFuture.isCancelled(), "isCancelled should return true for a cancelled Future"); }
/*********************************************/ @Override public boolean isDone() { return isDone.get() || isCancelled(); }
/*********************************************/ @Override public boolean isDone() { return isDone.get() || isCancelled(); }
/*********************************************/ @Override public boolean isDone() { return isDone.get() || isCancelled(); }
/*********************************************/ @Override public boolean isDone() { return isDone.get() || isCancelled(); }
private V getContent() throws ExecutionException { if (isCancelled()) throw new CancellationException(); ExecutionException e = exEx.get(); if (e != null) throw e; V update = content.get(); // No more retry currentRetry.set(maxRetry); if (!contentProcessed.getAndSet(true)) { try { update = asyncHandler.onCompleted(); } catch (Throwable ex) { if (!onThrowableCalled.getAndSet(true)) { try { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.debug("asyncHandler.onThrowable", t); } throw new RuntimeException(ex); } finally { cancelTimeouts(); } } } content.compareAndSet(null, update); } return update; }
private V getContent() throws ExecutionException { if (isCancelled()) throw new CancellationException(); ExecutionException e = exEx.get(); if (e != null) throw e; V update = content.get(); // No more retry currentRetry.set(maxRetry); if (!contentProcessed.getAndSet(true)) { try { update = asyncHandler.onCompleted(); } catch (Throwable ex) { if (!onThrowableCalled.getAndSet(true)) { try { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.debug("asyncHandler.onThrowable", t); } throw new RuntimeException(ex); } finally { cancelTimeouts(); } } } content.compareAndSet(null, update); } return update; }
private V getContent() throws ExecutionException { if (isCancelled()) throw new CancellationException(); ExecutionException e = exEx.get(); if (e != null) throw e; V update = content.get(); // No more retry currentRetry.set(maxRetry); if (!contentProcessed.getAndSet(true)) { try { update = asyncHandler.onCompleted(); } catch (Throwable ex) { if (!onThrowableCalled.getAndSet(true)) { try { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.debug("asyncHandler.onThrowable", t); } throw new RuntimeException(ex); } finally { cancelTimeouts(); } } } content.compareAndSet(null, update); } return update; }
private V getContent() throws ExecutionException { if (isCancelled()) throw new CancellationException(); ExecutionException e = exEx.get(); if (e != null) throw e; V update = content.get(); // No more retry currentRetry.set(maxRetry); if (!contentProcessed.getAndSet(true)) { try { update = asyncHandler.onCompleted(); } catch (Throwable ex) { if (!onThrowableCalled.getAndSet(true)) { try { try { asyncHandler.onThrowable(ex); } catch (Throwable t) { LOGGER.debug("asyncHandler.onThrowable", t); } throw new RuntimeException(ex); } finally { cancelTimeouts(); } } } content.compareAndSet(null, update); } return update; }