Program: 9044
Project: 9044
Buggy source:
/** 
 * Apply the changes to the MongoMK (to update the cache).
 */
public void applyToCache(){
  HashMap<String,ArrayList<String>> nodesWithChangedChildren=new HashMap<String,ArrayList<String>>();
  ArrayList<String> addOrRemove=new ArrayList<String>();
  addOrRemove.addAll(addedNodes);
  addOrRemove.addAll(removedNodes);
  for (  String p : addOrRemove) {
    String parent=PathUtils.getParentPath(p);
    ArrayList<String> list=nodesWithChangedChildren.get(parent);
    if (list == null) {
      list=new ArrayList<String>();
      nodesWithChangedChildren.put(parent,list);
    }
    list.add(p);
  }
  for (  String path : changedNodes) {
    ArrayList<String> added=new ArrayList<String>();
    ArrayList<String> removed=new ArrayList<String>();
    ArrayList<String> changed=nodesWithChangedChildren.get(path);
    if (changed != null) {
      for (      String s : changed) {
        if (addedNodes.contains(s)) {
          added.add(s);
        }
 else         if (removedNodes.contains(s)) {
          removed.add(s);
        }
      }
    }
    UpdateOp op=operations.get(path);
    boolean isNew=op != null && op.isNew;
    boolean isWritten=op != null;
    long writeCountInc=mk.getWriteCountIncrement(path);
    Long writeCount=writeCounts.get(path);
    if (writeCount == null) {
      if (isNew) {
        writeCount=0L;
        writeCountInc=0;
      }
 else {
        writeCountInc++;
        String id=Node.convertPathToDocumentId(path);
        Map<String,Object> map=mk.getDocumentStore().find(Collection.NODES,id);
        Long oldWriteCount=(Long)map.get(UpdateOp.WRITE_COUNT);
        writeCount=oldWriteCount == null ? 0 : oldWriteCount;
      }
    }
    mk.applyChanges(revision,path,isNew,isWritten,writeCount,writeCountInc,added,removed);
  }
}

Fixed version (ground truth):
/** 
 * Apply the changes to the MongoMK (to update the cache).
 */
public void applyToCache(){
  HashMap<String,ArrayList<String>> nodesWithChangedChildren=new HashMap<String,ArrayList<String>>();
  ArrayList<String> addOrRemove=new ArrayList<String>();
  addOrRemove.addAll(addedNodes);
  addOrRemove.addAll(removedNodes);
  for (  String p : addOrRemove) {
    String parent=PathUtils.getParentPath(p);
    ArrayList<String> list=nodesWithChangedChildren.get(parent);
    if (list == null) {
      list=new ArrayList<String>();
      nodesWithChangedChildren.put(parent,list);
    }
    list.add(p);
  }
  for (  String path : changedNodes) {
    ArrayList<String> added=new ArrayList<String>();
    ArrayList<String> removed=new ArrayList<String>();
    ArrayList<String> changed=nodesWithChangedChildren.get(path);
    if (changed != null) {
      for (      String s : changed) {
        if (addedNodes.contains(s)) {
          added.add(s);
        }
 else         if (removedNodes.contains(s)) {
          removed.add(s);
        }
      }
    }
    UpdateOp op=operations.get(path);
    boolean isNew=op != null && op.isNew;
    boolean isWritten=op != null;
    boolean isDelete=op != null && op.isDelete;
    long writeCountInc=mk.getWriteCountIncrement(path);
    Long writeCount=writeCounts.get(path);
    if (writeCount == null) {
      if (isNew) {
        writeCount=0L;
        writeCountInc=0;
      }
 else {
        writeCountInc++;
        String id=Node.convertPathToDocumentId(path);
        Map<String,Object> map=mk.getDocumentStore().find(Collection.NODES,id);
        Long oldWriteCount=(Long)map.get(UpdateOp.WRITE_COUNT);
        writeCount=oldWriteCount == null ? 0 : oldWriteCount;
      }
    }
    mk.applyChanges(revision,path,isNew,isDelete,isWritten,writeCount,writeCountInc,added,removed);
  }
}