Program: 88496
Project: 88496
Buggy source:
/** 
 * Get vertex associated to value. If object is managed by a service, we ask this service the value
 * @param value value we want the vertex for
 * @param cascade used cascade type, can be either {@link CascadeType#PERSIST} or {@link CascadeType#MERGE}
 * @param objectsBeingUpdated map of objects currently being updated, it avoid some loops during update, but is absolutely NOT a persistent cache
 * @return
 */
public Vertex getVertexFor(Object value,CascadeType cascade,Map<String,Object> objectsBeingUpdated){
  if (containedClass.isInstance(value)) {
    Vertex returned=getIdVertexFor(containedClass.cast(value));
    if (returned == null) {
      doUpdate(containedClass.cast(value),cascade,objectsBeingUpdated);
      returned=getIdVertexFor(containedClass.cast(value));
    }
 else {
      if (CascadeType.PERSIST == cascade || CascadeType.MERGE == cascade) {
        doUpdate(containedClass.cast(value),cascade,objectsBeingUpdated);
      }
    }
    return returned;
  }
  Class<? extends Object> valueClass=value.getClass();
  if (repository.containsKey(valueClass)) {
    FinderCrudService service=repository.get(valueClass);
    if (service instanceof BluePrintsBackedFinderService) {
      return ((BluePrintsBackedFinderService)service).getVertexFor(value,cascade,objectsBeingUpdated);
    }
 else {
      throw new IncompatibleServiceException(service,valueClass);
    }
  }
 else   if (Literals.containsKey(valueClass)) {
    return GraphUtils.getVertexForLiteral(database,value);
  }
 else   if (Tuples.containsKey(valueClass)) {
    return GraphUtils.getVertexForTuple(this,repository,value,objectsBeingUpdated);
  }
 else {
    throw new ObjectIsNotARealLiteralException(value,valueClass);
  }
}

Fixed version (ground truth):
/** 
 * Get vertex associated to value. If object is managed by a service, we ask this service the value
 * @param value value we want the vertex for
 * @param cascade used cascade type, can be either {@link CascadeType#PERSIST} or {@link CascadeType#MERGE}
 * @param objectsBeingUpdated map of objects currently being updated, it avoid some loops during update, but is absolutely NOT a persistent cache
 * @return
 */
public Vertex getVertexFor(Object value,CascadeType cascade,Map<String,Object> objectsBeingUpdated){
  boolean allowIdGeneration=CascadeType.PERSIST.equals(cascade) || CascadeType.MERGE.equals(cascade);
  if (containedClass.isInstance(value)) {
    Vertex returned=getIdVertexFor(containedClass.cast(value),allowIdGeneration);
    if (returned == null) {
      doUpdate(containedClass.cast(value),cascade,objectsBeingUpdated);
      returned=getIdVertexFor(containedClass.cast(value),allowIdGeneration);
    }
 else {
      if (CascadeType.PERSIST == cascade || CascadeType.MERGE == cascade) {
        doUpdate(containedClass.cast(value),cascade,objectsBeingUpdated);
      }
    }
    return returned;
  }
  Class<? extends Object> valueClass=value.getClass();
  if (repository.containsKey(valueClass)) {
    FinderCrudService service=repository.get(valueClass);
    if (service instanceof BluePrintsBackedFinderService) {
      return ((BluePrintsBackedFinderService)service).getVertexFor(value,cascade,objectsBeingUpdated);
    }
 else {
      throw new IncompatibleServiceException(service,valueClass);
    }
  }
 else   if (Literals.containsKey(valueClass)) {
    return GraphUtils.getVertexForLiteral(database,value);
  }
 else   if (Tuples.containsKey(valueClass)) {
    return GraphUtils.getVertexForTuple(this,repository,value,objectsBeingUpdated);
  }
 else {
    throw new ObjectIsNotARealLiteralException(value,valueClass);
  }
}