@Override public void call() { whenHandshaked.addListener(f -> { if (f.isSuccess()) { sendNextRequest(nextRequest, future); } else { future.abort(f.cause()); } } ); } });
private boolean abortOnThrowable(Channel channel, Throwable cause) { if (cause != null) { if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) { LOGGER.debug(cause.getMessage(), cause); Channels.silentlyCloseChannel(channel); } else { future.abort(cause); } return true; } return false; }
public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) { if (channel != null && channel.isActive()) { channelManager.closeChannel(channel); } if (!future.isDone()) { future.setChannelState(ChannelState.CLOSED); LOGGER.debug("Aborting Future {}\n", future); LOGGER.debug(t.getMessage(), t); future.abort(t); } }
@Override protected void error(Throwable error) { assertNotNull(error, "error"); removeFromPipeline(); future.abort(error); }
@Test(expectedExceptions = ExecutionException.class) public void testGetThrowsExceptionOnAbort() throws InterruptedException, ExecutionException { AsyncHandler<?> asyncHandler = mock(AsyncHandler.class); NettyResponseFuture<?> nettyResponseFuture = new NettyResponseFuture<>(null, asyncHandler, null, 3, null, null, null); nettyResponseFuture.abort(new RuntimeException()); nettyResponseFuture.get(); fail("An ExecutionException must have occurred by now as 'abort' was called before 'get'"); } }
public void onFailure(Channel channel, Throwable cause) { // beware, channel can be null Channels.silentlyCloseChannel(channel); boolean canRetry = future.incrementRetryAndCheck(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry// && cause != null // FIXME when can we have a null cause? && (future.getChannelState() != ChannelState.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) { return; } } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); String message = cause.getMessage() != null ? cause.getMessage() : future.getUri().getBaseUrl(); ConnectException e = new ConnectException(message); e.initCause(cause); future.abort(e); } }
@Override public void onError(Throwable t) { future.abort(t); } });
@Override protected void error(Throwable error) { if(error == null) throw null; removeFromPipeline(); future.abort(error); }
public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) { if (channel != null) channelManager.closeChannel(channel); if (!future.isDone()) { LOGGER.debug("Aborting Future {}\n", future); LOGGER.debug(t.getMessage(), t); future.abort(t); } }
public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) { if (channel != null) channelManager.closeChannel(channel); if (!future.isDone()) { LOGGER.debug("Aborting Future {}\n", future); LOGGER.debug(t.getMessage(), t); future.abort(t); } }
public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) { if (channel != null) channelManager.closeChannel(channel); if (!future.isDone()) { future.setState(NettyResponseFuture.STATE.CLOSED); LOGGER.debug("Aborting Future {}\n", future); LOGGER.debug(t.getMessage(), t); future.abort(t); } }
public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) { if (channel != null) channelManager.closeChannel(channel); if (!future.isDone()) { future.setState(NettyResponseFuture.STATE.CLOSED); LOGGER.debug("Aborting Future {}\n", future); LOGGER.debug(t.getMessage(), t); future.abort(t); } }
private boolean abortOnThrowable(Throwable cause, Channel channel) { if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) { if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) { LOGGER.debug(cause.getMessage(), cause); Channels.silentlyCloseChannel(channel); } else { future.abort(cause); } return true; } return false; }
private boolean abortOnThrowable(Throwable cause, Channel channel) { if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) { if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) { LOGGER.debug(cause.getMessage(), cause); Channels.silentlyCloseChannel(channel); } else { future.abort(cause); } return true; } return false; }
private boolean abortOnThrowable(Throwable cause, Channel channel) { if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) { // The write operation failed. If the channel was cached, it means it got asynchronously closed. // Let's retry a second time. if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) { LOGGER.debug(cause == null ? "" : cause.getMessage(), cause); Channels.silentlyCloseChannel(channel); } else { future.abort(cause); } return true; } return false; }
private boolean abortOnThrowable(Throwable cause, Channel channel) { if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) { // The write operation failed. If the channel was cached, it means it got asynchronously closed. // Let's retry a second time. if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) { LOGGER.debug(cause == null ? "" : cause.getMessage(), cause); Channels.silentlyCloseChannel(channel); } else { future.abort(cause); } return true; } return false; }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry && cause != null && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) return; } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) { e.initCause(cause); } future.abort(e); }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry// && cause != null// && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) { return; } } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) e.initCause(cause); future.abort(e); }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry// && cause != null// && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) { return; } } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) e.initCause(cause); future.abort(e); }
private void onFutureFailure(Channel channel, Throwable cause) { abortChannelPreemption(); boolean canRetry = future.canRetry(); LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry); if (canRetry && cause != null && (future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNettyDisconnectException(cause))) { if (requestSender.retry(future)) return; } LOGGER.debug("Failed to recover from connect exception: {} with channel {}", cause, channel); boolean printCause = cause != null && cause.getMessage() != null; String printedCause = printCause ? cause.getMessage() : getBaseUrl(future.getUri()); ConnectException e = new ConnectException(printedCause); if (cause != null) { e.initCause(cause); } future.abort(e); }