Source:
public void start() { bootstrap = new ClientBootstrap( new NioClientSocketChannelFactory( newCachedThreadPool( daemon( getClass().getSimpleName() + "-boss@" + destination ) ), newCachedThreadPool( daemon( getClass().getSimpleName() + "-worker@" + destination ) ) ) ); bootstrap.setPipelineFactory( this ); channelPool = new ResourcePool<ChannelContext>( maxUnusedChannels, new ResourcePool.CheckStrategy.TimeoutCheckStrategy( DEFAULT_CHECK_INTERVAL, Clocks.systemClock() ), new LoggingResourcePoolMonitor( msgLog ) ) { @Override protected ChannelContext create() { msgLog.info( threadInfo() + "Trying to open a new channel from " + origin + " to " + destination, Boolean.TRUE ); ChannelFuture channelFuture = bootstrap.connect( destination, origin ); channelFuture.awaitUninterruptibly( 5, TimeUnit.SECONDS ); if ( channelFuture.isSuccess() ) { msgLog.info( threadInfo() + "Opened a new channel from " + channelFuture.getChannel().getLocalAddress() + " to " + channelFuture.getChannel().getRemoteAddress() ); return new ChannelContext( channelFuture.getChannel(), ChannelBuffers.dynamicBuffer(), ByteBuffer.allocate( 1024 * 1024 ) ); } Throwable cause = channelFuture.getCause(); String msg = Client.this.getClass().getSimpleName() + " could not connect from " + origin + " to " + destination; msgLog.debug( msg, Boolean.TRUE ); throw traceComException( new ComException( msg, cause ), "Client.start" ); } @Override protected boolean isAlive( ChannelContext context ) { return context.channel().isConnected(); } @Override protected void dispose( ChannelContext context ) { Channel channel = context.channel(); if ( channel.isConnected() ) { msgLog.info( threadInfo() + "Closing: " + context + ". " + "Channel pool size is now " + currentSize() ); channel.close(); } } private String threadInfo() { return "Thread[" + Thread.currentThread().getId() + ", " + Thread.currentThread().getName() + "] "; } }; resourcePoolReleaser = () -> { if ( channelPool != null ) { channelPool.release(); } }; }

Target:
public void start() { bootstrap = new ClientBootstrap( new NioClientSocketChannelFactory( newCachedThreadPool( daemon( getClass().getSimpleName() + "-boss@" + destination ) ), newCachedThreadPool( daemon( getClass().getSimpleName() + "-worker@" + destination ) ) ) ); bootstrap.setPipelineFactory( this ); channelPool = new ResourcePool<ChannelContext>( maxUnusedChannels, new ResourcePool.CheckStrategy.TimeoutCheckStrategy( DEFAULT_CHECK_INTERVAL, Clocks.systemClock() ), new LoggingResourcePoolMonitor( msgLog ) ) { @Override protected ChannelContext create() { msgLog.info( threadInfo() + "Trying to open a new channel from " + origin + " to " + destination ); ChannelFuture channelFuture = bootstrap.connect( destination, origin ); channelFuture.awaitUninterruptibly( 5, TimeUnit.SECONDS ); if ( channelFuture.isSuccess() ) { msgLog.info( threadInfo() + "Opened a new channel from " + channelFuture.getChannel().getLocalAddress() + " to " + channelFuture.getChannel().getRemoteAddress() ); return new ChannelContext( channelFuture.getChannel(), ChannelBuffers.dynamicBuffer(), ByteBuffer.allocate( 1024 * 1024 ) ); } Throwable cause = channelFuture.getCause(); String msg = Client.this.getClass().getSimpleName() + " could not connect from " + origin + " to " + destination; msgLog.debug( msg ); throw traceComException( new ComException( msg, cause ), "Client.start" ); } @Override protected boolean isAlive( ChannelContext context ) { return context.channel().isConnected(); } @Override protected void dispose( ChannelContext context ) { Channel channel = context.channel(); if ( channel.isConnected() ) { msgLog.info( threadInfo() + "Closing: " + context + ". " + "Channel pool size is now " + currentSize() ); channel.close(); } } private String threadInfo() { return "Thread[" + Thread.currentThread().getId() + ", " + Thread.currentThread().getName() + "] "; } }; resourcePoolReleaser = () -> { if ( channelPool != null ) { channelPool.release(); } }; }