Buggy code:
class RemoteConnectionProvider extends AbstractHandleableCloseable < ConnectionProvider > implements ConnectionProvider { static final boolean USE_POOLING ; static final boolean LEAK_DEBUGGING ; private final RemoteConnectionProvider . ProviderInterface providerInterface = new RemoteConnectionProvider . ProviderInterface ( ) ; private final Xnio xnio ; private final XnioWorker xnioWorker ; private final ConnectionProviderContext connectionProviderContext ; private final boolean sslEnabled ; private final Collection < Cancellable > pendingInboundConnections = Collections . synchronizedSet ( new HashSet < Cancellable > ( ) ) ; private final Set < RemoteConnectionHandler > handlers = Collections . synchronizedSet ( new HashSet < RemoteConnectionHandler > ( ) ) ; private final MBeanServer server ; private final ObjectName objectName ; private final int defaultBufferSize ; RemoteConnectionProvider ( final OptionMap optionMap , final ConnectionProviderContext connectionProviderContext ) throws IOException { } private void doDumpConnectionState ( ) { } private void doGetConnectionState ( final StringBuilder b ) { } private String doGetConnectionState ( ) { } public Cancellable connect ( final SocketAddress bindAddress , final SocketAddress destination , final OptionMap connectOptions , final Result < ConnectionHandlerFactory > result , final CallbackHandler callbackHandler , XnioSsl xnioSsl ) throws IllegalArgumentException { if ( ! ( isOpen ( ) ) ) { throw new IllegalStateException ( "Connection<seq2seq4repair_space>provider<seq2seq4repair_space>is<seq2seq4repair_space>closed" ) ; } if ( destination == null ) { throw new IllegalArgumentException ( "destination<seq2seq4repair_space>address<seq2seq4repair_space>may<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>null" ) ; } if ( ( ( bindAddress != null ) && ( destination != null ) ) && ( ( bindAddress . getClass ( ) ) != ( destination . getClass ( ) ) ) ) { throw new IllegalArgumentException ( "bind<seq2seq4repair_space>and<seq2seq4repair_space>destination<seq2seq4repair_space>addresses<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>type" ) ; } RemoteLogger . log . tracef ( "Attempting<seq2seq4repair_space>to<seq2seq4repair_space>connect<seq2seq4repair_space>to<seq2seq4repair_space>\"%s\"<seq2seq4repair_space>with<seq2seq4repair_space>options<seq2seq4repair_space>%s" , destination , connectOptions ) ; final FutureResult < ConnectionHandlerFactory > cancellableResult = new FutureResult < ConnectionHandlerFactory > ( ) ; cancellableResult . addCancelHandler ( new Cancellable ( ) { @ Override public Cancellable cancel ( ) { cancellableResult . setCancelled ( ) ; return this ; } } ) ; final IoFuture < ConnectionHandlerFactory > returnedFuture = cancellableResult . getIoFuture ( ) ; returnedFuture . addNotifier ( IoUtils . < ConnectionHandlerFactory > resultNotifier ( ) , result ) ; final boolean sslCapable = sslEnabled ; final boolean useSsl = ( sslCapable && ( connectOptions . get ( SSL_ENABLED , true ) ) ) && ( ! ( connectOptions . get ( SECURE , false ) ) ) ; final AccessControlContext accessControlContext = AccessController . getContext ( ) ; final ChannelListener < ConnectedStreamChannel > openListener = new ChannelListener < ConnectedStreamChannel > ( ) { public void handleEvent ( final ConnectedStreamChannel channel ) { try { channel . setOption ( TCP_NODELAY , Boolean . TRUE ) ; } catch ( IOException e ) { } final int messageBufferSize = defaultBufferSize ; Pool < ByteBuffer > messageBufferPool = ( RemoteConnectionProvider . USE_POOLING ) ? new org . xnio . ByteBufferSlicePool ( BufferAllocator . BYTE_BUFFER_ALLOCATOR , messageBufferSize , ( messageBufferSize * 2 ) ) : Buffers . allocatedBufferPool ( BYTE_BUFFER_ALLOCATOR , messageBufferSize ) ; if ( RemoteConnectionProvider . LEAK_DEBUGGING ) messageBufferPool = new DebuggingBufferPool ( messageBufferPool ) ; final int framingBufferSize = messageBufferSize + 4 ; Pool < ByteBuffer > framingBufferPool = ( RemoteConnectionProvider . USE_POOLING ) ? new org . xnio . ByteBufferSlicePool ( BufferAllocator . BYTE_BUFFER_ALLOCATOR , framingBufferSize , ( framingBufferSize * 2 ) ) : Buffers . allocatedBufferPool ( BYTE_BUFFER_ALLOCATOR , framingBufferSize ) ; if ( RemoteConnectionProvider . LEAK_DEBUGGING ) <START_BUG> framingBufferPool = new DebuggingBufferPool ( messageBufferPool ) ; <END_BUG> final FramedMessageChannel messageChannel = new FramedMessageChannel ( channel , framingBufferPool . allocate ( ) , framingBufferPool . allocate ( ) ) ; final RemoteConnection remoteConnection = new RemoteConnection ( messageBufferPool , channel , messageChannel , connectOptions , RemoteConnectionProvider . this ) ; cancellableResult . addCancelHandler ( new Cancellable ( ) { @ Override public Cancellable cancel ( ) { RemoteConnectionHandler . sendCloseRequestBody ( remoteConnection ) ; remoteConnection . handlePreAuthCloseRequest ( ) ; return this ; } } ) ; if ( messageChannel . isOpen ( ) ) { remoteConnection . setResult ( cancellableResult ) ; messageChannel . getWriteSetter ( ) . set ( remoteConnection . getWriteListener ( ) ) ; final ClientConnectionOpenListener openListener = new ClientConnectionOpenListener ( remoteConnection , connectionProviderContext , callbackHandler , accessControlContext , connectOptions ) ; openListener . handleEvent ( messageChannel ) ; } } } ; final IoFuture < ? extends ConnectedStreamChannel > future ; if ( useSsl && ( destination instanceof InetSocketAddress ) ) { if ( xnioSsl == null ) { try { xnioSsl = xnio . getSslProvider ( connectOptions ) ; } catch ( GeneralSecurityException e ) { result . setException ( RemoteConnectionProvider . sslConfigFailure ( e ) ) ; return IoUtils . nullCancellable ( ) ; } } future = createSslConnection ( bindAddress , ( ( InetSocketAddress ) ( destination ) ) , connectOptions , xnioSsl , openListener ) ; } else { future = createConnection ( bindAddress , destination , connectOptions , openListener ) ; } pendingInboundConnections . add ( returnedFuture ) ; future . addNotifier ( new HandlingNotifier < ConnectedStreamChannel , FutureResult < ConnectionHandlerFactory > > ( ) { public void handleFailed ( final IOException exception , final FutureResult < ConnectionHandlerFactory > attachment ) { attachment . setException ( exception ) ; } public void handleCancelled ( final FutureResult < ConnectionHandlerFactory > attachment ) { attachment . setCancelled ( ) ; } } , cancellableResult ) ; returnedFuture . addNotifier ( new HandlingNotifier < ConnectionHandlerFactory , IoFuture < ConnectionHandlerFactory > > ( ) { public void handleCancelled ( IoFuture < ConnectionHandlerFactory > attachment ) { pendingInboundConnections . remove ( attachment ) ; future . cancel ( ) ; } public void handleFailed ( final IOException exception , IoFuture < ConnectionHandlerFactory > attachment ) { pendingInboundConnections . remove ( attachment ) ; } public void handleDone ( final ConnectionHandlerFactory data , IoFuture < ConnectionHandlerFactory > attachment ) { pendingInboundConnections . remove ( attachment ) ; } } , returnedFuture ) ; return returnedFuture ; }

Fix:
framingBufferPool = new DebuggingBufferPool ( framingBufferPool ) ;