Program: 9019
Project: 9019
Buggy source:
/** 
 * Apply the changes to the document store (to update MongoDB).
 * @param baseRevision the base revision of this commit. Currently onlyused for branch commits.
 */
void applyToDocumentStore(Revision baseRevision){
  String commitValue=baseRevision != null ? baseRevision.toString() : "String_Node_Str";
  DocumentStore store=mk.getDocumentStore();
  String commitRootPath=null;
  if (baseRevision != null) {
    commitRootPath="String_Node_Str";
  }
  ArrayList<UpdateOp> newNodes=new ArrayList<UpdateOp>();
  ArrayList<UpdateOp> changedNodes=new ArrayList<UpdateOp>();
  ArrayList<UpdateOp> done=new ArrayList<UpdateOp>();
  for (  String p : operations.keySet()) {
    markChanged(p);
    if (commitRootPath == null) {
      commitRootPath=p;
    }
 else {
      while (!PathUtils.isAncestor(commitRootPath,p)) {
        commitRootPath=PathUtils.getParentPath(commitRootPath);
        if (PathUtils.denotesRoot(commitRootPath)) {
          break;
        }
      }
    }
  }
  int commitRootDepth=PathUtils.getDepth(commitRootPath);
  UpdateOp commitRoot=getUpdateOperationForNode(commitRootPath);
  for (  String p : operations.keySet()) {
    UpdateOp op=operations.get(p);
    op.setMapEntry(UpdateOp.LAST_REV + "String_Node_Str" + revision.getClusterId(),revision.toString());
    if (op.isNew) {
      op.addMapEntry(UpdateOp.DELETED + "String_Node_Str" + revision.toString(),"String_Node_Str");
    }
    if (op == commitRoot) {
    }
 else {
      op.addMapEntry(UpdateOp.COMMIT_ROOT + "String_Node_Str" + revision.toString(),commitRootDepth);
      if (op.isNew()) {
        newNodes.add(op);
      }
 else {
        changedNodes.add(op);
      }
    }
  }
  if (changedNodes.size() == 0 && commitRoot.isNew) {
    commitRoot.addMapEntry(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString(),commitValue);
    newNodes.add(commitRoot);
  }
  try {
    if (newNodes.size() > 0) {
      if (!store.create(Collection.NODES,newNodes)) {
        for (        UpdateOp op : newNodes) {
          op.unset(UpdateOp.ID);
          if (op == commitRoot) {
            commitRoot.unset(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString());
          }
          changedNodes.add(op);
        }
        newNodes.clear();
      }
    }
    for (    UpdateOp op : changedNodes) {
      op.addMapEntry(UpdateOp.COMMIT_ROOT + "String_Node_Str" + revision.toString(),commitRootDepth);
      done.add(op);
      createOrUpdateNode(store,op);
    }
    if (changedNodes.size() > 0 || !commitRoot.isNew) {
      commitRoot.addMapEntry(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString(),commitValue);
      done.add(commitRoot);
      createOrUpdateNode(store,commitRoot);
      operations.put(commitRootPath,commitRoot);
    }
  }
 catch (  MicroKernelException e) {
    rollback(newNodes,done);
    String msg="String_Node_Str" + diff.toString();
    LOG.error(msg,e);
    throw new MicroKernelException(msg,e);
  }
}

Fixed version (ground truth):
/** 
 * Apply the changes to the document store (to update MongoDB).
 * @param baseRevision the base revision of this commit. Currently onlyused for branch commits.
 */
void applyToDocumentStore(Revision baseRevision){
  String commitValue=baseRevision != null ? baseRevision.toString() : "String_Node_Str";
  DocumentStore store=mk.getDocumentStore();
  String commitRootPath=null;
  if (baseRevision != null) {
    commitRootPath="String_Node_Str";
  }
  ArrayList<UpdateOp> newNodes=new ArrayList<UpdateOp>();
  ArrayList<UpdateOp> changedNodes=new ArrayList<UpdateOp>();
  ArrayList<UpdateOp> done=new ArrayList<UpdateOp>();
  for (  String p : operations.keySet()) {
    markChanged(p);
    if (commitRootPath == null) {
      commitRootPath=p;
    }
 else {
      while (!PathUtils.isAncestor(commitRootPath,p)) {
        commitRootPath=PathUtils.getParentPath(commitRootPath);
        if (PathUtils.denotesRoot(commitRootPath)) {
          break;
        }
      }
    }
  }
  int commitRootDepth=PathUtils.getDepth(commitRootPath);
  UpdateOp commitRoot=getUpdateOperationForNode(commitRootPath);
  for (  String p : operations.keySet()) {
    UpdateOp op=operations.get(p);
    op.setMapEntry(UpdateOp.LAST_REV + "String_Node_Str" + revision.getClusterId(),revision.toString());
    if (op.isNew) {
      op.addMapEntry(UpdateOp.DELETED + "String_Node_Str" + revision.toString(),"String_Node_Str");
    }
    if (op == commitRoot) {
    }
 else {
      op.addMapEntry(UpdateOp.COMMIT_ROOT + "String_Node_Str" + revision.toString(),commitRootDepth);
      if (op.isNew()) {
        newNodes.add(op);
      }
 else {
        changedNodes.add(op);
      }
    }
  }
  if (changedNodes.size() == 0 && commitRoot.isNew) {
    commitRoot.addMapEntry(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString(),commitValue);
    newNodes.add(commitRoot);
  }
  try {
    if (newNodes.size() > 0) {
      if (!store.create(Collection.NODES,newNodes)) {
        for (        UpdateOp op : newNodes) {
          if (op == commitRoot) {
            commitRoot.unset(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString());
          }
          changedNodes.add(op);
        }
        newNodes.clear();
      }
    }
    for (    UpdateOp op : changedNodes) {
      op.addMapEntry(UpdateOp.COMMIT_ROOT + "String_Node_Str" + revision.toString(),commitRootDepth);
      done.add(op);
      createOrUpdateNode(store,op);
    }
    if (changedNodes.size() > 0 || !commitRoot.isNew) {
      commitRoot.addMapEntry(UpdateOp.REVISIONS + "String_Node_Str" + revision.toString(),commitValue);
      done.add(commitRoot);
      createOrUpdateNode(store,commitRoot);
      operations.put(commitRootPath,commitRoot);
    }
  }
 catch (  MicroKernelException e) {
    rollback(newNodes,done);
    String msg="String_Node_Str" + diff.toString();
    LOG.error(msg,e);
    throw new MicroKernelException(msg,e);
  }
}