public boolean retry(NettyResponseFuture<?> future) { if (isClosed()) { return false; } if (future.isReplayPossible()) { future.setChannelState(ChannelState.RECONNECTED); LOGGER.debug("Trying to recover request {}\n", future.getNettyRequest().getHttpRequest()); try { future.getAsyncHandler().onRetry(); } catch (Exception e) { LOGGER.error("onRetry crashed", e); abort(future.channel(), future, e); return false; } try { sendNextRequest(future.getCurrentRequest(), future); return true; } catch (Exception e) { abort(future.channel(), future, e); return false; } } else { LOGGER.debug("Unable to recover future {}\n", future); return false; } }
public boolean applyIoExceptionFiltersAndReplayRequest(NettyResponseFuture<?> future, IOException e, Channel channel) { boolean replayed = false; @SuppressWarnings({"unchecked", "rawtypes"}) FilterContext<?> fc = new FilterContext.FilterContextBuilder().asyncHandler(future.getAsyncHandler()) .request(future.getCurrentRequest()).ioException(e).build(); for (IOExceptionFilter asyncFilter : config.getIoExceptionFilters()) { try { fc = asyncFilter.filter(fc); assertNotNull(fc, "filterContext"); } catch (FilterException efe) { abort(channel, future, efe); } } if (fc.replayRequest() && future.incrementRetryAndCheck() && future.isReplayPossible()) { future.setKeepAlive(false); replayRequest(future, fc, channel); replayed = true; } return replayed; }