Program: 91387
Project: 91387
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",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);
          }
        }
        socketChannelRef.set(socketChannel);
        socketChannelEntryWriter.sendWelcomeMessage(socketChannel,map.lastModification(),map.getIdentifier());
        final SocketChannelEntryReader.WelcomeMessage welcomeMessage=socketChannelEntryReader.readWelcomeMessage(socketChannel);
        final ReplicatedSharedHashMap.ModificationIterator remoteModificationIterator=map.acquireModificationIterator(welcomeMessage.identifier);
        remoteModificationIterator.dirtyEntries(welcomeMessage.timeStamp);
        socketChannel.configureBlocking(false);
        final Selector selector=Selector.open();
        socketChannel.register(selector,SelectionKey.OP_READ | SelectionKey.OP_WRITE);
        while (!isClosed.get()) {
          int n=selector.select();
          if (n == 0) {
            continue;
          }
          final Iterator it=selector.selectedKeys().iterator();
          while (it.hasNext()) {
            SelectionKey key=(SelectionKey)it.next();
            if (key.isReadable()) {
              socketChannelEntryReader.readAll(socketChannel);
            }
 else             if (key.isWritable()) {
              socketChannelEntryWriter.writeAll(socketChannel,remoteModificationIterator);
            }
            it.remove();
          }
        }
      }
 catch (      Exception e) {
        if (!isClosed.get()) {
          LOG.log(Level.SEVERE,"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",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);
          }
        }
        socketChannelRef.set(socketChannel);
        socketChannelEntryWriter.sendWelcomeMessage(socketChannel,map.lastModification(),map.getIdentifier());
        final SocketChannelEntryReader.WelcomeMessage welcomeMessage=socketChannelEntryReader.readWelcomeMessage(socketChannel);
        final ReplicatedSharedHashMap.ModificationIterator remoteModificationIterator=map.acquireModificationIterator(welcomeMessage.identifier);
        remoteModificationIterator.dirtyEntries(welcomeMessage.timeStamp);
        socketChannel.configureBlocking(false);
        final Selector selector=Selector.open();
        socketChannel.register(selector,SelectionKey.OP_READ | SelectionKey.OP_WRITE);
        while (!isClosed.get()) {
          int n=selector.select();
          if (n == 0) {
            continue;
          }
          final Iterator it=selector.selectedKeys().iterator();
          while (it.hasNext()) {
            SelectionKey key=(SelectionKey)it.next();
            if (key.isReadable()) {
              final SocketChannel socketChannel0=(SocketChannel)key.channel();
              socketChannelEntryReader.readAll(socketChannel0);
            }
 else             if (key.isWritable()) {
              final SocketChannel socketChannel0=(SocketChannel)key.channel();
              socketChannelEntryWriter.writeAll(socketChannel0,remoteModificationIterator);
            }
            it.remove();
          }
        }
      }
 catch (      Exception e) {
        if (!isClosed.get()) {
          LOG.log(Level.SEVERE,"String_Node_Str",e);
        }
      }
    }
  }
);
}