Program: 163063
Project: 163063
Buggy source:
/** 
 * used to exchange identifiers and timestamps and heartbeat intervals between the server and client
 * @param key           the SelectionKey relating to the this cha
 * @param socketChannel
 * @throws java.io.IOException
 * @throws InterruptedException
 */
private void doHandShaking(@NotNull final SelectionKey key,SocketChannel socketChannel) throws IOException, InterruptedException {
  final Attached attached=(Attached)key.attachment();
  final TcpSocketChannelEntryWriter writer=attached.entryWriter;
  final TcpSocketChannelEntryReader reader=attached.entryReader;
  if (attached.remoteIdentifier == Byte.MIN_VALUE) {
    final byte remoteIdentifier=reader.identifierFromBuffer();
    if (remoteIdentifier == Byte.MIN_VALUE)     return;
    attached.remoteIdentifier=remoteIdentifier;
    selectionKeysStore[remoteIdentifier]=key;
    activeKeys.set(remoteIdentifier);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",localIdentifier,remoteIdentifier);
    }
    final IdentifierListener identifierListener=replicationConfig.identifierListener;
    final SocketAddress remoteAddress=socketChannel.getRemoteAddress();
    boolean identifierIsUnique;
    if (identifierListener != null) {
      identifierIsUnique=identifierListener.isIdentifierUnique(remoteIdentifier,remoteAddress);
    }
 else {
      identifierIsUnique=remoteIdentifier != localIdentifier;
    }
    if (identifierIsUnique) {
      throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + remoteIdentifier);
    }
    attached.remoteModificationIterator=replica.acquireModificationIterator(remoteIdentifier,attached);
    writer.writeRemoteBootstrapTimestamp(replica.lastModificationTime(remoteIdentifier));
    writer.writeRemoteHeartbeatInterval(heartBeatIntervalMillis);
  }
  if (attached.remoteBootstrapTimestamp == Long.MIN_VALUE) {
    attached.remoteBootstrapTimestamp=reader.remoteBootstrapTimestamp();
    if (attached.remoteBootstrapTimestamp == Long.MIN_VALUE)     return;
  }
  if (!attached.hasRemoteHeartbeatInterval) {
    long value=reader.remoteHeartbeatIntervalFromBuffer();
    if (value == Long.MIN_VALUE)     return;
    if (value < 0) {
      LOG.error("String_Node_Str" + value);
    }
    attached.remoteHeartbeatInterval=(long)(value * 1.25);
    selectorTimeout=Math.min(selectorTimeout,value);
    if (selectorTimeout < 0)     LOG.info("String_Node_Str");
    attached.hasRemoteHeartbeatInterval=true;
    attached.handShakingComplete=true;
    attached.remoteModificationIterator.dirtyEntries(attached.remoteBootstrapTimestamp);
    reader.entriesFromBuffer();
  }
}

Fixed version (ground truth):
/** 
 * used to exchange identifiers and timestamps and heartbeat intervals between the server and client
 * @param key           the SelectionKey relating to the this cha
 * @param socketChannel
 * @throws java.io.IOException
 * @throws InterruptedException
 */
private void doHandShaking(@NotNull final SelectionKey key,SocketChannel socketChannel) throws IOException, InterruptedException {
  final Attached attached=(Attached)key.attachment();
  final TcpSocketChannelEntryWriter writer=attached.entryWriter;
  final TcpSocketChannelEntryReader reader=attached.entryReader;
  if (attached.remoteIdentifier == Byte.MIN_VALUE) {
    final byte remoteIdentifier=reader.identifierFromBuffer();
    if (remoteIdentifier == Byte.MIN_VALUE)     return;
    attached.remoteIdentifier=remoteIdentifier;
    selectionKeysStore[remoteIdentifier]=key;
    activeKeys.set(remoteIdentifier);
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",localIdentifier,remoteIdentifier);
    }
    final IdentifierListener identifierListener=replicationConfig.identifierListener;
    final SocketAddress remoteAddress=socketChannel.getRemoteAddress();
    if ((identifierListener != null && !identifierListener.isIdentifierUnique(remoteIdentifier,remoteAddress)) || remoteIdentifier == localIdentifier)     throw new IllegalStateException("String_Node_Str" + "String_Node_Str" + remoteIdentifier);
    attached.remoteModificationIterator=replica.acquireModificationIterator(remoteIdentifier,attached);
    writer.writeRemoteBootstrapTimestamp(replica.lastModificationTime(remoteIdentifier));
    writer.writeRemoteHeartbeatInterval(heartBeatIntervalMillis);
  }
  if (attached.remoteBootstrapTimestamp == Long.MIN_VALUE) {
    attached.remoteBootstrapTimestamp=reader.remoteBootstrapTimestamp();
    if (attached.remoteBootstrapTimestamp == Long.MIN_VALUE)     return;
  }
  if (!attached.hasRemoteHeartbeatInterval) {
    long value=reader.remoteHeartbeatIntervalFromBuffer();
    if (value == Long.MIN_VALUE)     return;
    if (value < 0) {
      LOG.error("String_Node_Str" + value);
    }
    attached.remoteHeartbeatInterval=(long)(value * 1.25);
    selectorTimeout=Math.min(selectorTimeout,value);
    if (selectorTimeout < 0)     LOG.info("String_Node_Str");
    attached.hasRemoteHeartbeatInterval=true;
    attached.handShakingComplete=true;
    attached.remoteModificationIterator.dirtyEntries(attached.remoteBootstrapTimestamp);
    reader.entriesFromBuffer();
  }
}