class HouseKeeper extends ChannelInboundHandlerAdapter {

    @Override
    public void exceptionCaught( ChannelHandlerContext ctx, Throwable cause )
    {
        if ( failed || isShuttingDown( ctx ) )
        {
            return;
        }
        failed = true; // log only the first exception to not pollute the log

        try
        {
            // Netty throws a NativeIoException on connection reset - directly importing that class
            // caused a host of linking errors, because it depends on JNI to work. Hence, we just
            // test on the message we know we'll get.
            if ( Exceptions.contains( cause, e -> e.getMessage().contains( "Connection reset by peer" ) ) )
            {
                log.warn( "Fatal error occurred when handling a client connection, " + "remote peer unexpectedly closed connection: %s", ctx.channel() );
            }
            else
            {
                log.error( "Fatal error occurred when handling a client connection: " + ctx.channel(), cause );
            }
        }
        finally
        {
            ctx.close();
        }
    }

    public  HouseKeeper( BoltConnection connection, Log log );

}