Program: 86821
Project: 86821
Buggy source:
/** 
 * Parses the packet; reads in the protocol headers and queuing up Messages for the Peer.
 * @param buffer
 * @throws IOException
 */
private void parsePacket(IOBuffer buffer) throws IOException {
  if (log.enabled()) {
    log.debug("String_Node_Str" + buffer.limit() + "String_Node_Str"+ receivedAddress);
  }
  protocol.reset();
  protocol.readFrom(buffer,messageFactory);
  if (protocol.isValid()) {
    byte peerId=protocol.getPeerId();
    if (peerId == INVALID_PEER_ID) {
      peerId=handleConnectionRequest(buffer,protocol);
    }
    if (isValidPeerId(peerId)) {
      if (!isServer && peers[peerId] == null) {
        peers[peerId]=localPeer;
        peers[peerId].setState(State.CONNECTED);
        peers[peerId].receive(new ConnectionRequestMessage());
      }
      Peer peer=peers[peerId];
      if (peer == null) {
        if (log.enabled()) {
          log.error("String_Node_Str" + peerId + "String_Node_Str");
        }
      }
 else {
        peer.setId(peerId);
        peer.setAddress(receivedAddress);
        peer.setLastReceivedTime(System.currentTimeMillis());
        peer.addNumberOfBytesRecv(buffer.limit());
        int seqNumber=protocol.getSendSequence();
        if (peer.isSequenceMoreRecent(seqNumber)) {
          peer.setRemoteSequence(seqNumber);
          peer.setRemoteAck(protocol.getAckHistory(),protocol.getAcknowledge());
          parseMessages(peer,buffer,protocol);
        }
 else {
          peer.addDroppedPacket();
          if (log.enabled()) {
            log.error("String_Node_Str" + seqNumber + "String_Node_Str"+ peer.getRemoteSequence());
          }
        }
      }
    }
 else {
      if (log.enabled()) {
        log.error("String_Node_Str" + peerId + "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Parses the packet; reads in the protocol headers and queuing up Messages for the Peer.
 * @param buffer
 * @throws IOException
 */
private void parsePacket(IOBuffer buffer) throws IOException {
  if (log.enabled()) {
    log.debug("String_Node_Str" + buffer.limit() + "String_Node_Str"+ receivedAddress);
  }
  protocol.reset();
  protocol.readFrom(buffer,messageFactory);
  if (protocol.isValid()) {
    byte peerId=protocol.getPeerId();
    if (peerId == INVALID_PEER_ID) {
      peerId=handleConnectionRequest(buffer,protocol);
    }
    if (isValidPeerId(peerId)) {
      if (!isServer && peers[peerId] == null) {
        peers[peerId]=localPeer;
        peers[peerId].setState(State.CONNECTED);
        peers[peerId].receive(new ConnectionRequestMessage());
      }
      Peer peer=peers[peerId];
      if (peer == null) {
        if (log.enabled()) {
          log.error("String_Node_Str" + peerId + "String_Node_Str");
        }
      }
 else {
        peer.setId(peerId);
        peer.setAddress(receivedAddress);
        peer.setLastReceivedTime(System.currentTimeMillis());
        peer.addNumberOfBytesRecv(buffer.limit());
        int seqNumber=protocol.getSendSequence();
        if (peer.isSequenceMoreRecent(seqNumber)) {
          int numberOfDroppedPackets=seqNumber - peer.getRemoteSequence();
          if (numberOfDroppedPackets > 1) {
            peer.addDroppedPacket(numberOfDroppedPackets);
          }
          peer.setRemoteSequence(seqNumber);
          peer.setRemoteAck(protocol.getAckHistory(),protocol.getAcknowledge());
          parseMessages(peer,buffer,protocol);
        }
 else {
          peer.addDroppedPacket();
          if (log.enabled()) {
            log.error("String_Node_Str" + seqNumber + "String_Node_Str"+ peer.getRemoteSequence());
          }
        }
      }
    }
 else {
      if (log.enabled()) {
        log.error("String_Node_Str" + peerId + "String_Node_Str");
      }
    }
  }
}