Program: 91345
Project: 91345
Buggy source:
public ClientTcpSocketReplicator(@NotNull final ClientPort clientPort,@NotNull final SocketChannelEntryReader socketChannelEntryReader,@NotNull final SocketChannelEntryWriter socketChannelEntryWriter,@NotNull final ReplicatedSharedHashMap map){
  newSingleThreadExecutor(new NamedThreadFactory("String_Node_Str" + map.getIdentifier(),true)).execute(new Runnable(){
    @Override public void run(){
      try {
        SocketChannel socketChannel=null;
        for (; ; ) {
          try {
            socketChannel=SocketChannel.open(new InetSocketAddress(clientPort.host,clientPort.port));
            LOG.info("String_Node_Str" + clientPort);
            socketChannel.socket().setReceiveBufferSize(8 * 1024);
            break;
          }
 catch (          ConnectException e) {
            if (socketChannel != null)             socketChannel.close();
            Thread.sleep(100);
          }
        }
        LOG.info("String_Node_Str" + map.getIdentifier());
        socketChannelRef.set(socketChannel);
        socketChannelEntryWriter.sendBootstrap(socketChannel,map.lastModification(),map.getIdentifier());
        final SocketChannelEntryReader.Bootstrap bootstrap=socketChannelEntryReader.readBootstrap(socketChannel);
        final ReplicatedSharedHashMap.ModificationIterator remoteModificationIterator=map.acquireModificationIterator(bootstrap.identifier);
        remoteModificationIterator.dirtyEntries(bootstrap.timeStamp);
        if (bootstrap.identifier == map.getIdentifier())         throw new IllegalStateException("String_Node_Str" + map.getIdentifier());
        LOG.info("String_Node_Str" + map.getIdentifier() + "String_Node_Str"+ bootstrap.identifier);
        socketChannel.configureBlocking(false);
        final Selector selector=Selector.open();
        socketChannel.register(selector,SelectionKey.OP_READ | SelectionKey.OP_WRITE);
        while (socketChannel.isOpen()) {
          final int n=selector.select();
          if (n == 0) {
            continue;
          }
          final Iterator it=selector.selectedKeys().iterator();
          while (it.hasNext()) {
            SelectionKey key=(SelectionKey)it.next();
            it.remove();
            try {
              if (key.isConnectable()) {
                LOG.info("String_Node_Str");
              }
              if (!key.isValid()) {
                continue;
              }
              if (key.isReadable()) {
                final SocketChannel socketChannel0=(SocketChannel)key.channel();
                socketChannelEntryReader.readAll(socketChannel0);
              }
              if (key.isWritable()) {
                final SocketChannel socketChannel0=(SocketChannel)key.channel();
                socketChannelEntryWriter.writeAll(socketChannel0,remoteModificationIterator);
              }
            }
 catch (            Exception e) {
              if (socketChannel.isOpen())               LOG.info("String_Node_Str",e);
              try {
                key.channel().close();
              }
 catch (              IOException ex) {
              }
            }
          }
        }
      }
 catch (      Exception e) {
        final SocketChannel socketChannel=socketChannelRef.get();
        if (socketChannel != null && socketChannel.isOpen()) {
          LOG.info("String_Node_Str",e);
        }
      }
    }
  }
);
}

Fixed version (ground truth):
public ClientTcpSocketReplicator(@NotNull final ClientPort clientPort,@NotNull final SocketChannelEntryReader socketChannelEntryReader,@NotNull final SocketChannelEntryWriter socketChannelEntryWriter,@NotNull final ReplicatedSharedHashMap map){
  newSingleThreadExecutor(new NamedThreadFactory("String_Node_Str" + map.getIdentifier(),true)).execute(new Runnable(){
    @Override public void run(){
      try {
        SocketChannel socketChannel=null;
        for (; ; ) {
          try {
            socketChannel=SocketChannel.open(new InetSocketAddress(clientPort.host,clientPort.port));
            LOG.info("String_Node_Str" + clientPort + "String_Node_Str"+ map.getIdentifier());
            break;
          }
 catch (          ConnectException e) {
            if (socketChannel != null)             socketChannel.close();
            Thread.sleep(100);
          }
        }
        socketChannelRef.set(socketChannel);
        socketChannel.socket().setReceiveBufferSize(8 * 1024);
        socketChannelEntryWriter.sendBootstrap(socketChannel,map.lastModification(),map.getIdentifier());
        final SocketChannelEntryReader.Bootstrap bootstrap=socketChannelEntryReader.readBootstrap(socketChannel);
        final ReplicatedSharedHashMap.ModificationIterator remoteModificationIterator=map.acquireModificationIterator(bootstrap.identifier);
        remoteModificationIterator.dirtyEntries(bootstrap.timeStamp);
        if (bootstrap.identifier == map.getIdentifier())         throw new IllegalStateException("String_Node_Str" + map.getIdentifier());
        LOG.info("String_Node_Str" + map.getIdentifier() + "String_Node_Str"+ bootstrap.identifier);
        socketChannel.configureBlocking(false);
        final Selector selector=Selector.open();
        socketChannel.register(selector,SelectionKey.OP_READ | SelectionKey.OP_WRITE);
        socketChannelEntryReader.readAll(socketChannel);
        while (socketChannel.isOpen()) {
          final int n=selector.select();
          if (n == 0) {
            continue;
          }
          final Iterator it=selector.selectedKeys().iterator();
          while (it.hasNext()) {
            SelectionKey key=(SelectionKey)it.next();
            it.remove();
            try {
              if (!key.isValid()) {
                continue;
              }
              if (key.isReadable()) {
                socketChannelEntryReader.readAll(socketChannel);
              }
              if (key.isWritable()) {
                socketChannelEntryWriter.writeAll(socketChannel,remoteModificationIterator);
              }
            }
 catch (            Exception e) {
              if (socketChannel.isOpen())               LOG.info("String_Node_Str",e);
              try {
                key.channel().close();
              }
 catch (              IOException ex) {
              }
            }
          }
        }
      }
 catch (      Exception e) {
        final SocketChannel socketChannel=socketChannelRef.get();
        if (socketChannel != null && socketChannel.isOpen()) {
          LOG.error("String_Node_Str",e);
        }
      }
    }
  }
);
}