@Override protected void cancelled() { logger.debug("Subscriber cancelled, ignoring the rest of the body"); try { future.done(); } catch (Exception t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } // The subscriber cancelled early - this channel is dead and should be closed. channelManager.closeChannel(channel); }
void finishUpdate(NettyResponseFuture<?> future, Channel channel, boolean close) { future.cancelTimeouts(); if (close) { channelManager.closeChannel(channel); } else { channelManager.tryToOfferChannelToPool(channel, future.getAsyncHandler(), true, future.getPartitionKey()); } try { future.done(); } catch (Exception t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } }
@Test(expectedExceptions = ExecutionException.class) public void testGetThrowsExceptionThrownByAsyncHandler() throws Exception { AsyncHandler<?> asyncHandler = mock(AsyncHandler.class); when(asyncHandler.onCompleted()).thenThrow(new RuntimeException()); NettyResponseFuture<?> nettyResponseFuture = new NettyResponseFuture<>(null, asyncHandler, null, 3, null, null, null); nettyResponseFuture.done(); nettyResponseFuture.get(); fail("An ExecutionException must have occurred by now as asyncHandler threw an exception in 'onCompleted'"); }
@Test public void testGet() throws Exception { @SuppressWarnings("unchecked") AsyncHandler<Object> asyncHandler = mock(AsyncHandler.class); Object value = new Object(); when(asyncHandler.onCompleted()).thenReturn(value); NettyResponseFuture<?> nettyResponseFuture = new NettyResponseFuture<>(null, asyncHandler, null, 3, null, null, null); nettyResponseFuture.done(); Object result = nettyResponseFuture.get(); assertEquals(result, value, "The Future should return the value given by asyncHandler#onCompleted"); }
logger.warn("onSuccess unexpected exception", ex); future.done();
@Override protected void cancelled() { logger.debug("Subscriber cancelled, ignoring the rest of the body"); // The subscriber cancelled early, we need to drain the remaining elements from the stream channelManager.drainChannelAndOffer(channel, future); channel.pipeline().remove(StreamedResponsePublisher.class); try { future.done(); } catch (Exception t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } }
private void finishUpdate(final NettyResponseFuture<?> future, Channel channel, boolean expectOtherChunks) throws IOException { future.cancelTimeouts(); boolean keepAlive = future.isKeepAlive(); if (expectOtherChunks && keepAlive) channelManager.drainChannelAndOffer(channel, future); else channelManager.tryToOfferChannelToPool(channel, keepAlive, future.getPartitionKey()); try { future.done(); } catch (Throwable t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } }
private void finishUpdate(final NettyResponseFuture<?> future, Channel channel, boolean expectOtherChunks) throws IOException { future.cancelTimeouts(); boolean keepAlive = future.isKeepAlive(); if (expectOtherChunks && keepAlive) channelManager.drainChannelAndOffer(channel, future); else channelManager.tryToOfferChannelToPool(channel, keepAlive, future.getPartitionKey()); try { future.done(); } catch (Throwable t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } }
private void finishUpdate(final NettyResponseFuture<?> future, Channel channel, boolean expectOtherChunks) { future.cancelTimeouts(); boolean keepAlive = future.isKeepAlive(); if (expectOtherChunks && keepAlive) channelManager.drainChannelAndOffer(channel, future); else channelManager.tryToOfferChannelToPool(channel, future.getAsyncHandler(), keepAlive, future.getPartitionKey()); try { future.done(); } catch (Exception t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } }
private void finishUpdate(final NettyResponseFuture<?> future, Channel channel, boolean expectOtherChunks) throws IOException { future.cancelTimeouts(); boolean keepAlive = future.isKeepAlive(); if (expectOtherChunks && keepAlive) channelManager.drainChannelAndOffer(channel, future); else channelManager.tryToOfferChannelToPool(channel, future.getAsyncHandler(), keepAlive, future.getPartitionKey()); try { future.done(); } catch (Exception t) { // Never propagate exception once we know we are done. logger.debug(t.getMessage(), t); } }