Program: 87211
Project: 87211
Buggy source:
/** 
 * @param aLowWatermark the current low watermark - sorter will use this to identify packets that potentiallycould be consumed.
 * @param aProcessor the processor that will be used to process any packets identified as acceptable or performrecovery. Recovery should do an atomic test and set to see if it wins the recovery race and act accordingly.
 * @return the number of packets processed
 */
int process(long aLowWatermark,PacketProcessor aProcessor){
  List<Transport.Packet> myConsumables=new LinkedList<>();
synchronized (this) {
    Iterator<Map.Entry<Long,List<Transport.Packet>>> mySeqsAndPkts=_packets.entrySet().iterator();
    while (mySeqsAndPkts.hasNext()) {
      Map.Entry<Long,List<Transport.Packet>> mySeqAndPkt=mySeqsAndPkts.next();
      if (mySeqAndPkt.getKey() <= (aLowWatermark + 1)) {
        myConsumables.addAll(_packets.get(mySeqAndPkt.getKey()));
        mySeqsAndPkts.remove();
      }
    }
  }
  if ((myConsumables.size() == 0) && (_packets.size() != 0)) {
    SortedSet<Long> myAllSeqs=new TreeSet<>(_packets.keySet());
    Long myLastSeq=myAllSeqs.last();
    if (myLastSeq > (aLowWatermark + MAX_INFLIGHT))     if (aProcessor.recover(new Need(aLowWatermark,myAllSeqs.last() - 1))) {
synchronized (this) {
        List<Transport.Packet> myLastPackets=_packets.get(myLastSeq);
        _packets.clear();
        _packets.put(myLastSeq,myLastPackets);
      }
    }
    return 0;
  }
 else {
    for (    Transport.Packet p : myConsumables)     aProcessor.consume(p);
    return myConsumables.size();
  }
}

Fixed version (ground truth):
/** 
 * @param aLowWatermark the current low watermark - sorter will use this to identify packets that potentiallycould be consumed.
 * @param aProcessor the processor that will be used to process any packets identified as acceptable or performrecovery. Recovery should do an atomic test and set to see if it wins the recovery race and act accordingly.
 * @return the number of packets processed
 */
int process(long aLowWatermark,PacketProcessor aProcessor){
  List<Transport.Packet> myConsumables=new LinkedList<>();
synchronized (this) {
    Iterator<Map.Entry<Long,List<Transport.Packet>>> mySeqsAndPkts=_packets.entrySet().iterator();
    while (mySeqsAndPkts.hasNext()) {
      Map.Entry<Long,List<Transport.Packet>> mySeqAndPkt=mySeqsAndPkts.next();
      if (mySeqAndPkt.getKey() <= (aLowWatermark + 1)) {
        myConsumables.addAll(_packets.get(mySeqAndPkt.getKey()));
        mySeqsAndPkts.remove();
      }
    }
  }
  if ((myConsumables.size() == 0) && (_packets.size() != 0)) {
    SortedSet<Long> myAllSeqs=new TreeSet<>(_packets.keySet());
    Long myLastSeq=myAllSeqs.last();
    if (myLastSeq > (aLowWatermark + MAX_INFLIGHT)) {
      InetSocketAddress myTriggerAddr=_packets.get(myLastSeq).get(0).getSource();
      if (aProcessor.recover(new Need(aLowWatermark,myAllSeqs.last() - 1),myTriggerAddr)) {
synchronized (this) {
          List<Transport.Packet> myLastPackets=_packets.get(myLastSeq);
          _packets.clear();
          _packets.put(myLastSeq,myLastPackets);
        }
      }
    }
    return 0;
  }
 else {
    for (    Transport.Packet p : myConsumables)     aProcessor.consume(p);
    return myConsumables.size();
  }
}