Program: 173031
Project: 173031
Buggy source:
/** 
 * Method used to progress work
 */
public void progress(){
  for (  int t : messages.keySet()) {
    if (batchDone.get(t)) {
      continue;
    }
    boolean allFinished=true;
    Map<Integer,List<Object>> map=messages.get(t);
    Map<Integer,Boolean> finishedForTarget=finished.get(t);
    Map<Integer,Integer> countMap=counts.get(t);
    if (!isStoreBased) {
      boolean found=true;
      for (      Map.Entry<Integer,List<Object>> e : map.entrySet()) {
        if (e.getValue().size() == 0 && !finishedForTarget.get(e.getKey())) {
          found=false;
        }
        if (!finishedForTarget.get(e.getKey())) {
          allFinished=false;
        }
      }
      if (found) {
        List<Object> out=new ArrayList<>();
        for (        Map.Entry<Integer,List<Object>> e : map.entrySet()) {
          List<Object> valueList=e.getValue();
          if (valueList.size() > 0) {
            Object value=valueList.get(0);
            out.add(value);
            allFinished=false;
            valueList.remove(0);
          }
        }
        finalMessages.get(t).addAll(out);
      }
 else {
        allFinished=false;
      }
    }
 else {
      for (      Map.Entry<Integer,List<Object>> e : map.entrySet()) {
        if (!finishedForTarget.get(e.getKey())) {
          allFinished=false;
        }
      }
    }
    if (allFinished) {
      batchDone.put(t,true);
      if (!isStoreBased) {
        gatherBatchReceiver.receive(t,finalMessages.get(t).iterator());
      }
 else {
        gatherBatchReceiver.receive(t,memoryManagers.get(t).iterator());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Method used to progress work
 */
public void progress(){
  for (  int t : messages.keySet()) {
    if (batchDone.get(t)) {
      continue;
    }
    boolean allFinished=true;
    Map<Integer,Queue<Object>> map=messages.get(t);
    Map<Integer,Boolean> finishedForTarget=finished.get(t);
    Map<Integer,Integer> countMap=counts.get(t);
    if (!isStoreBased) {
      boolean found=true;
      for (      Map.Entry<Integer,Queue<Object>> e : map.entrySet()) {
        if (e.getValue().size() == 0 && !finishedForTarget.get(e.getKey())) {
          found=false;
        }
        if (!finishedForTarget.get(e.getKey())) {
          allFinished=false;
        }
      }
      if (found) {
        List<Object> out=new ArrayList<>();
        for (        Map.Entry<Integer,Queue<Object>> e : map.entrySet()) {
          Queue<Object> valueList=e.getValue();
          if (valueList.size() > 0) {
            Object value=valueList.poll();
            out.add(value);
            allFinished=false;
          }
        }
        finalMessages.get(t).addAll(out);
      }
 else {
        allFinished=false;
      }
    }
 else {
      for (      Map.Entry<Integer,Queue<Object>> e : map.entrySet()) {
        if (!finishedForTarget.get(e.getKey())) {
          allFinished=false;
        }
      }
    }
    if (allFinished) {
      batchDone.put(t,true);
      if (!isStoreBased) {
        gatherBatchReceiver.receive(t,finalMessages.get(t).iterator());
      }
 else {
        gatherBatchReceiver.receive(t,memoryManagers.get(t).iterator());
      }
    }
  }
}