private boolean isHandledByReactiveStreams(ChannelHandlerContext ctx) { return Channels.getAttribute(ctx.channel()) instanceof StreamedResponsePublisher; }
Object attribute = Channels.getAttribute(channel);
Object attribute = Channels.getAttribute(channel); if (attribute instanceof StreamedResponsePublisher) { ctx.fireExceptionCaught(e);
public void channelInactive(ChannelHandlerContext ctx) throws Exception { if (requestSender.isClosed()) return; Channel channel = ctx.channel(); channelManager.removeAll(channel); Object attribute = Channels.getAttribute(channel); logger.debug("Channel Closed: {} with attribute {}", channel, attribute); if (attribute instanceof StreamedResponsePublisher) { // setting `attribute` to be the underlying future so that the retry // logic can kick-in attribute = ((StreamedResponsePublisher) attribute).future(); } if (attribute instanceof OnLastHttpContentCallback) { OnLastHttpContentCallback callback = (OnLastHttpContentCallback) attribute; Channels.setAttribute(channel, callback.future()); callback.call(); } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.touch(); if (hasIOExceptionFilters && requestSender.applyIoExceptionFiltersAndReplayRequest(future, ChannelClosedException.INSTANCE, channel)) return; handleChannelInactive(future); requestSender.handleUnexpectedClosedChannel(channel, future); } }
private boolean isHandledByReactiveStreams(ChannelHandlerContext ctx) { return Channels.getAttribute(ctx.channel()) instanceof StreamedResponsePublisher; } }
private boolean isChannelCloseable(Channel channel) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; if (!future.isDone()) { LOGGER.error("Future not in appropriate state %s, not closing", future); return false; } } return true; }
private boolean isChannelCloseable(Channel channel) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; if (!future.isDone()) { LOGGER.error("Future not in appropriate state %s, not closing", future); return false; } } return true; }
private boolean isChannelCloseable(Channel channel) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; if (!future.isDone()) { LOGGER.error("Future not in appropriate state %s, not closing", future); return false; } } return true; }
private boolean isChannelCloseable(Channel channel) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; if (!future.isDone()) { LOGGER.error("Future not in appropriate state %s, not closing", future); return false; } } return true; }
public void close() { channelPool.destroy(); openChannels.close(); for (Channel channel : openChannels) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.cancelTimeouts(); } } if (allowReleaseEventLoopGroup) eventLoopGroup.shutdownGracefully(); }
public void close() { channelPool.destroy(); openChannels.close(); for (Channel channel : openChannels) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.cancelTimeouts(); } } if (allowReleaseEventLoopGroup) eventLoopGroup.shutdownGracefully(config.getShutdownQuiet(), config.getShutdownTimeout(), TimeUnit.MILLISECONDS); }
@Override public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception { Channel channel = ctx.channel(); Object attribute = Channels.getAttribute(channel); if (attribute instanceof Callback) { Callback ac = (Callback) attribute; if (msg instanceof LastHttpContent) { ac.call(); } else if (!(msg instanceof HttpContent)) { LOGGER.info("Received unexpected message while expecting a chunk: " + msg); ac.call(); Channels.setDiscard(channel); } } else if (attribute instanceof NettyResponseFuture) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; protocol.handle(channel, future, msg); } else if (attribute != DiscardEvent.INSTANCE) { // unhandled message LOGGER.debug("Orphan channel {} with attribute {} received message {}, closing", channel, attribute, msg); Channels.silentlyCloseChannel(channel); } }
@Override public void messageReceived(final ChannelHandlerContext ctx, MessageEvent e) throws Exception { // call super to reset the read timeout super.messageReceived(ctx, e); Channel channel = ctx.getChannel(); Object attribute = Channels.getAttribute(channel); if (attribute instanceof Callback) { Object message = e.getMessage(); Callback ac = (Callback) attribute; if (message instanceof HttpChunk) { // the AsyncCallable is to be processed on the last chunk if (HttpChunk.class.cast(message).isLast()) // process the AsyncCallable before passing the message to the protocol ac.call(); // FIXME remove attribute? } else { LOGGER.info("Received unexpected message while expecting a chunk: " + message); ac.call(); Channels.setDiscard(channel); } } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; protocol.handle(channel, future, e.getMessage()); } else if (attribute != DiscardEvent.INSTANCE) { // unhandled message LOGGER.debug("Orphan channel {} with attribute {} received message {}, closing", channel, attribute, e.getMessage()); Channels.silentlyCloseChannel(channel); } }
@Override public void messageReceived(final ChannelHandlerContext ctx, MessageEvent e) throws Exception { // call super to reset the read timeout super.messageReceived(ctx, e); Channel channel = ctx.getChannel(); Object attribute = Channels.getAttribute(channel); if (attribute instanceof Callback) { Object message = e.getMessage(); Callback ac = (Callback) attribute; if (message instanceof HttpChunk) { // the AsyncCallable is to be processed on the last chunk if (HttpChunk.class.cast(message).isLast()) // process the AsyncCallable before passing the message to the protocol ac.call(); // FIXME remove attribute? } else { LOGGER.info("Received unexpected message while expecting a chunk: " + message); ac.call(); Channels.setDiscard(channel); } } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; protocol.handle(channel, future, e.getMessage()); } else if (attribute != DiscardEvent.INSTANCE) { // unhandled message LOGGER.debug("Orphan channel {} with attribute {} received message {}, closing", channel, attribute, e.getMessage()); Channels.silentlyCloseChannel(channel); } }
public void channelInactive(ChannelHandlerContext ctx) throws Exception { if (requestSender.isClosed()) return; Channel channel = ctx.channel(); channelManager.removeAll(channel); try { super.channelInactive(ctx); } 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.class.cast(attribute); future.touch(); if (!config.getIOExceptionFilters().isEmpty() && requestSender.applyIoExceptionFiltersAndReplayRequest(future, CHANNEL_CLOSED_EXCEPTION, channel)) return; protocol.onClose(future); requestSender.handleUnexpectedClosedChannel(channel, future); } }
public void close() { channelPool.destroy(); openChannels.close(); for (Channel channel : openChannels) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.cancelTimeouts(); } } // FIXME also shutdown in provider config.getExecutorService().shutdown(); if (allowReleaseSocketChannelFactory) { socketChannelFactory.releaseExternalResources(); httpBootstrap.releaseExternalResources(); wsBootstrap.releaseExternalResources(); } }
public void channelInactive(ChannelHandlerContext ctx) throws Exception { if (requestSender.isClosed()) return; Channel channel = ctx.channel(); channelManager.removeAll(channel); try { super.channelInactive(ctx); } catch (Exception ex) { LOGGER.trace("super.channelClosed", ex); } Object attribute = Channels.getAttribute(channel); LOGGER.debug("Channel Closed: {} with attribute {}", channel, attribute); if (attribute instanceof StreamedResponsePublisher) { // setting `attribute` to be the underlying future so that the retry // logic can kick-in attribute = ((StreamedResponsePublisher) attribute).future(); } if (attribute instanceof Callback) { Callback callback = (Callback) attribute; Channels.setAttribute(channel, callback.future()); callback.call(); } else if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = NettyResponseFuture.class.cast(attribute); future.touch(); if (!config.getIOExceptionFilters().isEmpty() && requestSender.applyIoExceptionFiltersAndReplayRequest(future, CHANNEL_CLOSED_EXCEPTION, channel)) return; protocol.onClose(future); requestSender.handleUnexpectedClosedChannel(channel, future); } }
@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 void close() { channelPool.destroy(); openChannels.close(); for (Channel channel : openChannels) { Object attribute = Channels.getAttribute(channel); if (attribute instanceof NettyResponseFuture<?>) { NettyResponseFuture<?> future = (NettyResponseFuture<?>) attribute; future.cancelTimeouts(); } } // FIXME also shutdown in provider config.executorService().shutdown(); if (allowReleaseSocketChannelFactory) { socketChannelFactory.releaseExternalResources(); plainBootstrap.releaseExternalResources(); secureBootstrap.releaseExternalResources(); webSocketBootstrap.releaseExternalResources(); secureWebSocketBootstrap.releaseExternalResources(); } }
@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); } }