Program: 5020
Project: 5020
Buggy source:
@Override public CloseableIterator<Entry> fetch(TopicMetadata metadata,long transactionWritePointer,MessageId messageId,final boolean inclusive,int limit) throws IOException {
  byte[] topic=MessagingUtils.toDataKeyPrefix(metadata.getTopicId(),metadata.getGeneration());
  final byte[] startRow=new byte[topic.length + (2 * Bytes.SIZEOF_LONG) + Bytes.SIZEOF_SHORT];
  byte[] stopRow=new byte[topic.length + Bytes.SIZEOF_LONG];
  Bytes.putBytes(startRow,0,topic,0,topic.length);
  Bytes.putBytes(stopRow,0,topic,0,topic.length);
  Bytes.putLong(startRow,topic.length,transactionWritePointer);
  Bytes.putLong(stopRow,topic.length,transactionWritePointer);
  Bytes.putLong(startRow,topic.length + Bytes.SIZEOF_LONG,messageId.getPayloadWriteTimestamp());
  Bytes.putShort(startRow,topic.length + (2 * Bytes.SIZEOF_LONG),messageId.getPayloadSequenceId());
  stopRow=Bytes.stopKeyForPrefix(stopRow);
  final CloseableIterator<RawPayloadTableEntry> scanner=read(startRow,stopRow,limit);
  return new AbstractCloseableIterator<Entry>(){
    private boolean closed=false;
    private byte[] skipStartRow=inclusive ? null : startRow;
    @Override protected Entry computeNext(){
      if (closed || (!scanner.hasNext())) {
        return endOfData();
      }
      RawPayloadTableEntry entry=scanner.next();
      if (skipStartRow != null) {
        byte[] row=skipStartRow;
        skipStartRow=null;
        if (Bytes.equals(row,entry.getKey()) && !scanner.hasNext()) {
          return endOfData();
        }
        entry=scanner.next();
      }
      return new ImmutablePayloadTableEntry(entry.getKey(),entry.getValue());
    }
    @Override public void close(){
      try {
        scanner.close();
      }
  finally {
        endOfData();
        closed=true;
      }
    }
  }
;
}

Fixed version (ground truth):
@Override public CloseableIterator<Entry> fetch(TopicMetadata metadata,long transactionWritePointer,MessageId messageId,final boolean inclusive,int limit) throws IOException {
  byte[] topic=MessagingUtils.toDataKeyPrefix(metadata.getTopicId(),metadata.getGeneration());
  final byte[] startRow=new byte[topic.length + (2 * Bytes.SIZEOF_LONG) + Bytes.SIZEOF_SHORT];
  byte[] stopRow=new byte[topic.length + Bytes.SIZEOF_LONG];
  Bytes.putBytes(startRow,0,topic,0,topic.length);
  Bytes.putBytes(stopRow,0,topic,0,topic.length);
  Bytes.putLong(startRow,topic.length,transactionWritePointer);
  Bytes.putLong(stopRow,topic.length,transactionWritePointer);
  Bytes.putLong(startRow,topic.length + Bytes.SIZEOF_LONG,messageId.getPayloadWriteTimestamp());
  Bytes.putShort(startRow,topic.length + (2 * Bytes.SIZEOF_LONG),messageId.getPayloadSequenceId());
  stopRow=Bytes.stopKeyForPrefix(stopRow);
  final CloseableIterator<RawPayloadTableEntry> scanner=read(startRow,stopRow,limit);
  return new AbstractCloseableIterator<Entry>(){
    private boolean closed=false;
    private boolean skipFirstRow=!inclusive;
    @Override protected Entry computeNext(){
      if (closed || (!scanner.hasNext())) {
        return endOfData();
      }
      RawPayloadTableEntry entry=scanner.next();
      if (skipFirstRow) {
        skipFirstRow=false;
        if (!scanner.hasNext()) {
          return endOfData();
        }
        entry=scanner.next();
      }
      return new ImmutablePayloadTableEntry(entry.getKey(),entry.getValue());
    }
    @Override public void close(){
      try {
        scanner.close();
      }
  finally {
        endOfData();
        closed=true;
      }
    }
  }
;
}