Program: 9045
Project: 9045
Buggy source:
/** 
 * Apply the changes to the document store (to update MongoDB).
 * @param store the store
 */
void applyToDocumentStore(){
  DocumentStore store=mk.getDocumentStore();
  String commitRoot=null;
  ArrayList<UpdateOp> newNodes=new ArrayList<UpdateOp>();
  ArrayList<UpdateOp> changedNodes=new ArrayList<UpdateOp>();
  for (  String p : operations.keySet()) {
    markChanged(p);
    if (commitRoot == null) {
      commitRoot=p;
    }
 else {
      while (!PathUtils.isAncestor(commitRoot,p)) {
        commitRoot=PathUtils.getParentPath(commitRoot);
        if (PathUtils.denotesRoot(commitRoot)) {
          break;
        }
      }
    }
  }
  UpdateOp root=getUpdateOperationForNode(commitRoot);
  for (  String p : operations.keySet()) {
    UpdateOp op=operations.get(p);
    if (op == root) {
    }
 else     if (op.isNew()) {
      newNodes.add(op);
    }
 else {
      changedNodes.add(op);
    }
  }
  if (changedNodes.size() == 0 && root.isNew) {
    newNodes.add(root);
    root=null;
  }
  try {
    if (newNodes.size() > 0) {
      store.create(Collection.NODES,newNodes);
    }
    for (    UpdateOp op : changedNodes) {
      createOrUpdateNode(store,op);
    }
    if (root != null) {
      long increment=mk.getWriteCountIncrement(commitRoot);
      root.increment(UpdateOp.WRITE_COUNT,1 + increment);
      root.addMapEntry(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString(),"String_Node_Str");
      createOrUpdateNode(store,root);
      operations.put(commitRoot,root);
    }
  }
 catch (  MicroKernelException e) {
    throw new MicroKernelException("String_Node_Str" + diff.toString(),e);
  }
}

Fixed version (ground truth):
/** 
 * Apply the changes to the document store (to update MongoDB).
 * @param store the store
 */
void applyToDocumentStore(){
  DocumentStore store=mk.getDocumentStore();
  String commitRoot=null;
  ArrayList<UpdateOp> newNodes=new ArrayList<UpdateOp>();
  ArrayList<UpdateOp> changedNodes=new ArrayList<UpdateOp>();
  for (  String p : operations.keySet()) {
    markChanged(p);
    if (commitRoot == null) {
      commitRoot=p;
    }
 else {
      while (!PathUtils.isAncestor(commitRoot,p)) {
        commitRoot=PathUtils.getParentPath(commitRoot);
        if (PathUtils.denotesRoot(commitRoot)) {
          break;
        }
      }
    }
  }
  UpdateOp root=getUpdateOperationForNode(commitRoot);
  for (  String p : operations.keySet()) {
    UpdateOp op=operations.get(p);
    if (op == root) {
    }
 else     if (op.isNew()) {
      newNodes.add(op);
    }
 else {
      changedNodes.add(op);
    }
  }
  if (changedNodes.size() == 0 && root.isNew) {
    newNodes.add(root);
    root=null;
  }
  try {
    if (newNodes.size() > 0) {
      if (!store.create(Collection.NODES,newNodes)) {
        for (        UpdateOp op : newNodes) {
          op.unset(UpdateOp.ID);
          op.addMapEntry(UpdateOp.DELETED + "String_Node_Str" + revision.toString(),"String_Node_Str");
          createOrUpdateNode(store,op);
        }
      }
    }
    for (    UpdateOp op : changedNodes) {
      createOrUpdateNode(store,op);
    }
    if (root != null) {
      long increment=mk.getWriteCountIncrement(commitRoot);
      root.increment(UpdateOp.WRITE_COUNT,1 + increment);
      root.addMapEntry(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString(),"String_Node_Str");
      createOrUpdateNode(store,root);
      operations.put(commitRoot,root);
    }
  }
 catch (  MicroKernelException e) {
    String msg="String_Node_Str" + diff.toString();
    LOG.error(msg,e);
    throw new MicroKernelException(msg,e);
  }
}