Program: 2923
Project: 2923
Buggy source:
@Override public StateReturnValue execute(ChannelBuffer buffer,IcapMessageDecoder icapMessageDecoder) throws Exception {
  IcapChunk chunk=null;
  if (icapMessageDecoder.message.isPreview()) {
    Matcher ieofMatcher=new Matcher(IcapCodecUtil.IEOF_SEQUENCE);
    ChannelBuffer previewBuffer=ChannelBuffers.dynamicBuffer();
    int counter=0;
    while (counter <= icapMessageDecoder.currentChunkSize) {
      Byte bite=null;
      try {
        bite=buffer.readByte();
        counter++;
      }
 catch (      IndexOutOfBoundsException ioobe) {
        return StateReturnValue.createIrrelevantResultWithDecisionInformation(ReadChunkStateProcessing.READ_CHUNK_AGAIN);
      }
      previewBuffer.writeByte(bite);
      if (ieofMatcher.addByteAndMatch(bite)) {
        int step=correctBufferIndex(buffer);
        ChannelBuffer ieofBuffer=previewBuffer.copy(0,previewBuffer.readableBytes() - (IcapCodecUtil.IEOF_SEQUENCE.length + step + 1));
        chunk=new DefaultIcapChunk(ieofBuffer);
        chunk.setIsPreviewChunk();
        chunk.setIsEarlyTerminated();
        icapMessageDecoder.currentChunkSize=0;
        return StateReturnValue.createRelevantResultWithDecisionInformation(chunk,ReadChunkStateProcessing.GO_TO_DELIMITER);
      }
    }
    chunk=new DefaultIcapChunk(previewBuffer.copy(0,previewBuffer.readableBytes() - 1));
    chunk.setIsPreviewChunk();
    return StateReturnValue.createRelevantResultWithDecisionInformation(chunk,ReadChunkStateProcessing.GO_TO_DELIMITER);
  }
 else {
    chunk=new DefaultIcapChunk(buffer.readBytes(icapMessageDecoder.currentChunkSize));
    return StateReturnValue.createRelevantResultWithDecisionInformation(chunk,ReadChunkStateProcessing.GO_TO_DELIMITER);
  }
}

Fixed version (ground truth):
@Override public StateReturnValue execute(ChannelBuffer buffer,IcapMessageDecoder icapMessageDecoder) throws Exception {
  IcapChunk chunk=null;
  if (icapMessageDecoder.message.isPreview()) {
    Matcher ieofMatcher=new Matcher(IcapCodecUtil.IEOF_SEQUENCE);
    ChannelBuffer previewBuffer=ChannelBuffers.dynamicBuffer();
    int counter=0;
    while (counter <= icapMessageDecoder.currentChunkSize) {
      Byte bite=null;
      try {
        bite=buffer.readByte();
        counter++;
      }
 catch (      IndexOutOfBoundsException ioobe) {
        return StateReturnValue.createIrrelevantResultWithDecisionInformation(ReadChunkStateProcessing.READ_CHUNK_AGAIN);
      }
      previewBuffer.writeByte(bite);
      if (ieofMatcher.addByteAndMatch(bite)) {
        int step=correctBufferIndex(buffer,IcapCodecUtil.IEOF_SEQUENCE.length);
        ChannelBuffer ieofBuffer=previewBuffer.copy(0,previewBuffer.readableBytes() - (IcapCodecUtil.IEOF_SEQUENCE.length + step));
        chunk=new DefaultIcapChunk(ieofBuffer);
        chunk.setIsPreviewChunk();
        chunk.setIsEarlyTerminated();
        icapMessageDecoder.currentChunkSize=0;
        return StateReturnValue.createRelevantResultWithDecisionInformation(chunk,ReadChunkStateProcessing.GO_TO_DELIMITER);
      }
    }
    int step=correctBufferIndex(buffer,0);
    chunk=new DefaultIcapChunk(previewBuffer.copy(0,previewBuffer.readableBytes() - step));
    chunk.setIsPreviewChunk();
    return StateReturnValue.createRelevantResultWithDecisionInformation(chunk,ReadChunkStateProcessing.GO_TO_DELIMITER);
  }
 else {
    chunk=new DefaultIcapChunk(buffer.readBytes(icapMessageDecoder.currentChunkSize));
    return StateReturnValue.createRelevantResultWithDecisionInformation(chunk,ReadChunkStateProcessing.GO_TO_DELIMITER);
  }
}