private FilterContext handleIoException(FilterContext fc) throws FilterException { for (IOExceptionFilter asyncFilter : config.getIOExceptionFilters()) { fc = asyncFilter.filter(fc); if (fc == null) { throw new NullPointerException("FilterContext is null"); } } return fc; }
public Protocol(ChannelManager channelManager, AsyncHttpClientConfig config, NettyAsyncHttpProviderConfig nettyConfig, NettyRequestSender requestSender) { this.channelManager = channelManager; this.config = config; this.nettyConfig = nettyConfig; this.requestSender = requestSender; hasResponseFilters = !config.getResponseFilters().isEmpty(); hasIOExceptionFilters = !config.getIOExceptionFilters().isEmpty(); maxRedirectException = new MaxRedirectException("Maximum redirect reached: " + config.getMaxRedirects()); }
if (!config.getIOExceptionFilters().isEmpty()) { if (!requestSender.applyIoExceptionFiltersAndReplayRequest(future, CHANNEL_CLOSED_EXCEPTION, channel))
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (requestSender.isClosed()) return; Channel channel = ctx.getChannel(); channelManager.removeAll(channel); try { super.channelClosed(ctx, e); } catch (Exception ex) { LOGGER.trace("super.channelClosed", ex); } Object attribute = Channels.getAttribute(channel); LOGGER.debug("Channel Closed: {} with attribute {}", channel, attribute); if (attribute instanceof Callback) { Callback callback = (Callback) attribute; Channels.setAttribute(channel, callback.future()); callback.call(); } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.touch(); if (!config.getIOExceptionFilters().isEmpty() && requestSender.applyIoExceptionFiltersAndReplayRequest(future, CHANNEL_CLOSED_EXCEPTION, channel)) return; protocol.onClose(future); requestSender.handleUnexpectedClosedChannel(channel, future); } }
public boolean applyIoExceptionFiltersAndReplayRequest(NettyResponseFuture<?> future, IOException e, Channel channel) throws IOException { boolean replayed = false; @SuppressWarnings({ "unchecked", "rawtypes" }) FilterContext<?> fc = new FilterContext.FilterContextBuilder().asyncHandler(future.getAsyncHandler()).request(future.getRequest()) .ioException(e).build(); for (IOExceptionFilter asyncFilter : config.getIOExceptionFilters()) { try { fc = asyncFilter.filter(fc); if (fc == null) { throw new NullPointerException("FilterContext is null"); } } catch (FilterException efe) { abort(channel, future, efe); } } if (fc.replayRequest() && future.canBeReplayed()) { replayRequest(future, fc, channel); replayed = true; } return replayed; }
ioExceptionFilters.addAll(prototype.getIOExceptionFilters());
logger.debug(t.getMessage(), t); if (t instanceof IOException && !config.getIOExceptionFilters().isEmpty()) { FilterContext fc = new FilterContext.FilterContextBuilder().asyncHandler(asyncHandler) .request(request).ioException(IOException.class.cast(t)).build();
private FilterContext handleIoException(FilterContext fc) throws FilterException { for (IOExceptionFilter asyncFilter : config.getIOExceptionFilters()) { fc = asyncFilter.filter(fc); if (fc == null) { throw new NullPointerException("FilterContext is null"); } } return fc; }
private FilterContext handleIoException(FilterContext fc) throws FilterException { for (IOExceptionFilter asyncFilter : config.getIOExceptionFilters()) { fc = asyncFilter.filter(fc); if (fc == null) { throw new NullPointerException("FilterContext is null"); } } return fc; } }
public Protocol(ChannelManager channelManager, AsyncHttpClientConfig config, NettyAsyncHttpProviderConfig nettyConfig, NettyRequestSender requestSender) { this.channelManager = channelManager; this.config = config; this.nettyConfig = nettyConfig; this.requestSender = requestSender; hasResponseFilters = !config.getResponseFilters().isEmpty(); hasIOExceptionFilters = !config.getIOExceptionFilters().isEmpty(); timeConverter = config.getTimeConverter(); }
if (!config.getIOExceptionFilters().isEmpty()) if (requestSender.applyIoExceptionFiltersAndReplayRequest(future, CHANNEL_CLOSED_EXCEPTION, channel)) return;
@Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { if (requestSender.isClosed()) return; Channel channel = ctx.getChannel(); channelManager.removeAll(channel); try { super.channelClosed(ctx, e); } catch (Exception ex) { LOGGER.trace("super.channelClosed", ex); } Object attribute = Channels.getAttribute(channel); LOGGER.debug("Channel Closed: {} with attribute {}", channel, attribute); if (attribute instanceof Callback) { Callback callback = (Callback) attribute; Channels.setAttribute(channel, callback.future()); callback.call(); } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.touch(); if (!config.getIOExceptionFilters().isEmpty() && requestSender.applyIoExceptionFiltersAndReplayRequest(future, CHANNEL_CLOSED_EXCEPTION, channel)) return; protocol.onClose(channel); if (future == null || future.isDone()) channelManager.closeChannel(channel); else if (!requestSender.retry(future, ctx.getChannel())) requestSender.abort(future, REMOTELY_CLOSED_EXCEPTION); } }
public boolean applyIoExceptionFiltersAndReplayRequest(NettyResponseFuture<?> future, IOException e, Channel channel) throws IOException { boolean replayed = false; @SuppressWarnings({ "unchecked", "rawtypes" }) FilterContext<?> fc = new FilterContext.FilterContextBuilder().asyncHandler(future.getAsyncHandler()).request(future.getRequest()) .ioException(e).build(); for (IOExceptionFilter asyncFilter : config.getIOExceptionFilters()) { try { fc = asyncFilter.filter(fc); if (fc == null) { throw new NullPointerException("FilterContext is null"); } } catch (FilterException efe) { abort(future, efe); } } if (fc.replayRequest() && future.canBeReplayed()) { replayRequest(future, fc, channel); replayed = true; } return replayed; }
ioExceptionFilters.addAll(prototype.getIOExceptionFilters());
logger.debug(t.getMessage(), t); if (t instanceof IOException && !config.getIOExceptionFilters().isEmpty()) { FilterContext fc = new FilterContext.FilterContextBuilder().asyncHandler(asyncHandler) .request(request).ioException(IOException.class.cast(t)).build();
ioExceptionFilters.addAll(prototype.getIOExceptionFilters());
ioExceptionFilters.addAll(prototype.getIOExceptionFilters());
if (t instanceof IOException && !config.getIOExceptionFilters().isEmpty()) { FilterContext fc = new FilterContext.FilterContextBuilder().asyncHandler(asyncHandler) .request(future.getRequest()).ioException(IOException.class.cast(t)).build();