Program: 88473
Project: 88473
Buggy source:
/** 
 * Update given collection by creating a set of edges/vertices for each element
 * @param p          properties to update associated vertices for
 * @param toUpdate   source object to update
 * @param rootVertex vertex associated to toUpdate
 * @param cascade    used cascade type, can be either {@link CascadeType#PERSIST} or {@link CascadeType#MERGE}
 * @category update
 */
private <DataType>void updateCollection(AbstractBluePrintsBackedFinderService<? extends Graph,DataType,?> service,Graph database,Property p,Object toUpdate,Vertex rootVertex,CascadeType cascade,Map<String,Object> objectsBeingAccessed){
  Collection<?> value=(Collection<?>)p.get(toUpdate);
  if (value != null) {
    Iterable<Edge> existingIterator=service.getStrategy().getOutEdgesFor(rootVertex,p);
    Collection<Vertex> newVertices=createCollectionVerticesFor(service,value,cascade,objectsBeingAccessed);
    Map<Vertex,Edge> oldVertices=new HashMap<Vertex,Edge>();
    for (    Edge e : existingIterator) {
      Vertex inVertex=e.getInVertex();
      if (newVertices.contains(inVertex)) {
        newVertices.remove(inVertex);
      }
 else {
        oldVertices.put(inVertex,e);
      }
    }
    for (    Map.Entry<Vertex,Edge> entry : oldVertices.entrySet()) {
      database.removeEdge(entry.getValue());
    }
    int order=0;
    for (    Vertex newVertex : newVertices) {
      Edge createdEdge=service.getDriver().createEdgeFor(rootVertex,newVertex,p);
      createdEdge.setProperty(Properties.collection_index.name(),order++);
    }
  }
}

Fixed version (ground truth):
/** 
 * Update given collection by creating a set of edges/vertices for each element
 * @param p          properties to update associated vertices for
 * @param toUpdate   source object to update
 * @param rootVertex vertex associated to toUpdate
 * @param cascade    used cascade type, can be either {@link CascadeType#PERSIST} or {@link CascadeType#MERGE}
 * @category update
 */
private <DataType>void updateCollection(AbstractBluePrintsBackedFinderService<? extends Graph,DataType,?> service,Graph database,Property p,Object toUpdate,Vertex rootVertex,CascadeType cascade,Map<String,Object> objectsBeingAccessed){
  Collection<?> value=(Collection<?>)p.get(toUpdate);
  if (value != null) {
    Iterable<Edge> existingEdges=service.getStrategy().getOutEdgesFor(rootVertex,p);
    Collection<Vertex> allVertices=createCollectionVerticesFor(service,value,cascade,objectsBeingAccessed);
    Map<Vertex,Edge> allEdges=new HashMap<Vertex,Edge>();
    Set<Edge> edgesToRemove=new HashSet<Edge>();
    for (    Edge e : existingEdges) {
      Vertex inVertex=e.getInVertex();
      if (allVertices.contains(inVertex)) {
        allEdges.put(inVertex,e);
      }
 else {
        edgesToRemove.add(e);
        allEdges.put(inVertex,null);
      }
    }
    for (    Edge edge : edgesToRemove) {
      database.removeEdge(edge);
    }
    int order=0;
    for (    Vertex vertex : allVertices) {
      Edge edgeForVertex=allEdges.get(vertex);
      if (edgeForVertex == null)       edgeForVertex=service.getDriver().createEdgeFor(rootVertex,vertex,p);
      edgeForVertex.setProperty(Properties.collection_index.name(),order++);
    }
  }
}