@Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        // First let other handlers do their thing ...
        // super.userEventTriggered(ctx, evt);

        if (evt instanceof IdleStateEvent) {
            // Log some info about this.
            idleCounter.increment();
            String msg = "Origin channel for origin - " + originName + " - idle timeout has fired. "
                    + ChannelUtils.channelInfoForLogging(ctx.channel());
            closeConnection(ctx, msg);
        } else if (evt instanceof CompleteEvent completeEvt) {
            // The HttpLifecycleChannelHandler instance will fire this event when either a response has finished being
            // written, or
            // the channel is no longer active or disconnected.
            // Return the connection to pool.
            CompleteReason reason = completeEvt.getReason();
            if (reason == CompleteReason.SESSION_COMPLETE) {
                PooledConnection conn = PooledConnection.getFromChannel(ctx.channel());
                if (conn != null) {
                    if ("close".equalsIgnoreCase(getConnectionHeader(completeEvt))) {
                        String msg = "Origin channel for origin - " + originName
                                + " - completed because of expired keep-alive. "
                                + ChannelUtils.channelInfoForLogging(ctx.channel());
                        headerCloseCounter.increment();
                        closeConnection(ctx, msg);
                    } else {
                        conn.setConnectionState(PooledConnection.ConnectionState.WRITE_READY);
                        conn.release();
                    }
                }
            } else {
                String msg = "Origin channel for origin - " + originName + " - completed with reason " + reason.name()
                        + ", " + ChannelUtils.channelInfoForLogging(ctx.channel());
                closeConnection(ctx, msg);
            }
        } else if (evt instanceof SslCloseCompletionEvent event) {
            sslCloseCompletionCounter.increment();
            String msg = "Origin channel for origin - " + originName + " - received SslCloseCompletionEvent " + event
                    + ". " + ChannelUtils.channelInfoForLogging(ctx.channel());
            closeConnection(ctx, msg);
        }
    }
User: michaels@netflix.com
Date: 6/23/16
Time: 1:57 PM
zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/ConnectionPoolHandler.java