Program: 6140
Project: 6140
Buggy source:
@Override public PartitionConsumerResult consumePartitions(PartitionConsumerState partitionConsumerState,int limit,Predicate<PartitionDetail> predicate){
  List<Long> previousInProgress=partitionConsumerState.getVersionsToCheck();
  Set<Long> noLongerInProgress=setDiff(previousInProgress,tx.getInProgress());
  List<PartitionDetail> partitions=Lists.newArrayList();
  Iterator<Long> iter=noLongerInProgress.iterator();
  while (iter.hasNext()) {
    Long txId=iter.next();
    if (partitions.size() >= limit) {
      break;
    }
    Scanner scanner=partitionsTable.readByIndex(WRITE_PTR_COL,Bytes.toBytes(txId));
    try {
      scannerToPartitions(scanner,partitions,limit,predicate);
    }
  finally {
      scanner.close();
    }
    iter.remove();
  }
  long scanUpTo;
  if (partitions.size() < limit) {
    scanUpTo=Math.min(tx.getWritePointer(),tx.getReadPointer() + 1);
    Scanner scanner=partitionsTable.scanByIndex(WRITE_PTR_COL,Bytes.toBytes(partitionConsumerState.getStartVersion()),Bytes.toBytes(scanUpTo));
    Long endTxId;
    try {
      endTxId=scannerToPartitions(scanner,partitions,limit,predicate);
    }
  finally {
      scanner.close();
    }
    if (endTxId != null) {
      scanUpTo=endTxId;
    }
  }
 else {
    scanUpTo=partitionConsumerState.getStartVersion();
  }
  List<Long> inProgressBeforeScanEnd=Lists.newArrayList(noLongerInProgress);
  for (  long txId : tx.getInProgress()) {
    if (txId >= scanUpTo) {
      break;
    }
    inProgressBeforeScanEnd.add(txId);
  }
  return new PartitionConsumerResult(new PartitionConsumerState(scanUpTo,inProgressBeforeScanEnd),partitions);
}

Fixed version (ground truth):
@Override public PartitionConsumerResult consumePartitions(PartitionConsumerState partitionConsumerState,int limit,Predicate<PartitionDetail> predicate){
  List<Long> previousInProgress=partitionConsumerState.getVersionsToCheck();
  Set<Long> noLongerInProgress=setDiff(previousInProgress,tx.getInProgress());
  List<PartitionDetail> partitions=Lists.newArrayList();
  Iterator<Long> iter=noLongerInProgress.iterator();
  while (iter.hasNext()) {
    Long txId=iter.next();
    if (partitions.size() >= limit) {
      break;
    }
    try (Scanner scanner=partitionsTable.readByIndex(WRITE_PTR_COL,Bytes.toBytes(txId))){
      scannerToPartitions(scanner,partitions,limit,predicate);
    }
     iter.remove();
  }
  long scanUpTo;
  if (partitions.size() < limit) {
    scanUpTo=Math.min(tx.getWritePointer(),tx.getReadPointer() + 1);
    Long endTxId;
    try (Scanner scanner=partitionsTable.scanByIndex(WRITE_PTR_COL,Bytes.toBytes(partitionConsumerState.getStartVersion()),Bytes.toBytes(scanUpTo))){
      endTxId=scannerToPartitions(scanner,partitions,limit,predicate);
    }
     if (endTxId != null) {
      scanUpTo=endTxId;
    }
  }
 else {
    scanUpTo=partitionConsumerState.getStartVersion();
  }
  List<Long> inProgressBeforeScanEnd=Lists.newArrayList(noLongerInProgress);
  for (  long txId : tx.getInProgress()) {
    if (txId >= scanUpTo) {
      break;
    }
    inProgressBeforeScanEnd.add(txId);
  }
  return new PartitionConsumerResult(new PartitionConsumerState(scanUpTo,inProgressBeforeScanEnd),partitions);
}