Program: 80493
Project: 80493
Buggy source:
/** 
 * @param context
 * @param fm
 * @param fieldIndex
 * @param level
 * @return true, if this leads to a null value
 */
@SuppressWarnings("String_Node_Str") private <T>boolean fillModel(FillModelContext<T> context,FieldMapping fm){
  int prevClauseRepetitionNumber=context.clauseRepetitionNumber;
  boolean isNullNode=false;
  String nnm=this.buildNodeOrRelationName(context.path,DomainAccessHandler.NodePrefix,context.clauseRepetitionNumber);
  context.setTerminatesClause(nnm);
  CompoundObjectType compoundType;
  if (fm == null)   compoundType=domainAccessHandler.getCompoundTypeFor(context.domainObjectClass);
 else {
    String classFieldName=fm.getClassFieldName();
    compoundType=MappingUtil.internalDomainAccess.get().getConcreteFieldType(classFieldName);
  }
  Class<? extends Object> pureType=fm != null ? fm.getFieldType() : context.domainObjectClass;
  if (compoundType != null) {
    context.path.add(new PathElement(pureType));
    boolean resolveDeep=true;
    if (context.queryEndNodes.contains(nnm)) {
      resolveDeep=false;
    }
    boolean isCollection=Collection.class.isAssignableFrom(pureType);
    Collection<Object> collection=null;
    if (isCollection) {
      String classFieldName=fm.getClassFieldName();
      collection=(Collection<Object>)domainAccessHandler.createInstance(MappingUtil.internalDomainAccess.get().getConcreteFieldType(classFieldName).getType());
      compoundType=MappingUtil.internalDomainAccess.get().getFieldComponentType(classFieldName);
    }
    JcNode n=new JcNode(nnm);
    List<GrNode> resList=context.qResult.resultOf(n);
    Object domainObject=null;
    if (resList.size() > 0) {
      for (      GrNode rNode : resList) {
        if (rNode != null) {
          boolean performMapping=false;
          boolean mapProperties=true;
          domainObject=domainAccessHandler.domainState.getFrom_Id2ObjectMap(rNode.getId());
          if (domainObject == null) {
            Class<?> clazz=domainAccessHandler.findClassToInstantiateFor(rNode);
            domainObject=domainAccessHandler.createInstance(clazz);
            domainAccessHandler.domainState.add_Id2Object(domainObject,rNode.getId(),resolveDeep ? ResolutionDepth.DEEP : ResolutionDepth.SHALLOW);
            performMapping=true;
          }
 else {
            if (resolveDeep && domainAccessHandler.domainState.getResolutionDepth(domainObject) != ResolutionDepth.DEEP) {
              performMapping=true;
              mapProperties=false;
            }
          }
          if (fm == null) {
            context.domainObject=(T)domainObject;
          }
          if (performMapping) {
            ObjectMapping objectMapping=domainAccessHandler.getCompoundObjectMappingFor(compoundType,domainObject.getClass());
            Iterator<FieldMapping> it=objectMapping.fieldMappingsIterator();
            int idx=0;
            while (it.hasNext()) {
              FieldMapping fMap=it.next();
              idx++;
              if (!objectMapping.shouldPerformFieldMapping(fMap)) {
                if (fMap.needsRelation() && resolveDeep) {
                  calculateMaxClauseRepetitionNumber(context,fMap,idx);
                }
                continue;
              }
              if (fMap.needsRelation() && resolveDeep) {
                context.currentObject=null;
                PathElement pe=context.getLastPathElement();
                pe.fieldIndex=idx;
                context.clauseRepetitionNumber=context.maxClauseRepetitionNumber;
                pe.fieldName=fMap.getFieldName();
                boolean nodeIsNull=this.fillModel(context,fMap);
                context.alreadyTested.clear();
                while (nodeIsNull && morePathsToTest(context,fMap,idx)) {
                  context.currentObject=null;
                  pe=context.getLastPathElement();
                  pe.fieldIndex=idx;
                  context.clauseRepetitionNumber=context.maxClauseRepetitionNumber;
                  pe.fieldName=fMap.getFieldName();
                  nodeIsNull=this.fillModel(context,fMap);
                }
                if (!nodeIsNull && context.currentObject != null) {
                  fMap.setField(domainObject,context.currentObject);
                  String rnm=this.buildNodeOrRelationName(context.path,DomainAccessHandler.RelationPrefix,context.clauseRepetitionNumber);
                  JcRelation r=new JcRelation(rnm);
                  List<GrRelation> relList=context.qResult.resultOf(r);
                  GrRelation rel=relList.get(0);
                  domainAccessHandler.domainState.add_Id2Relation(new Relation(fMap.getPropertyOrRelationName(),domainObject,context.currentObject),rel.getId());
                }
 else                 if (nodeIsNull && fMap.isCollection()) {
                  fMap.mapPropertyToField(domainObject,rNode);
                }
                context.updateMaxClauseRepetitionNumber();
              }
 else {
                if (mapProperties)                 fMap.mapPropertyToField(domainObject,rNode);
              }
            }
          }
          if (isCollection)           collection.add(domainObject);
        }
 else {
          isNullNode=true;
        }
      }
    }
    if (isCollection)     context.currentObject=collection;
 else     context.currentObject=domainObject;
    context.path.remove(context.path.size() - 1);
  }
  context.clauseRepetitionNumber=prevClauseRepetitionNumber;
  return isNullNode;
}

Fixed version (ground truth):
/** 
 * @param context
 * @param fm may be null
 * @param nodeName may be null
 * @return true, if this leads to a null value
 */
@SuppressWarnings("String_Node_Str") private <T>boolean fillModel(FillModelContext<T> context,FieldMapping fm,String nodeName){
  int prevClauseRepetitionNumber=context.clauseRepetitionNumber;
  boolean isNullNode=false;
  String nnm;
  if (nodeName != null)   nnm=nodeName;
 else   nnm=this.buildNodeOrRelationName(context.path,DomainAccessHandler.NodePrefix,context.clauseRepetitionNumber);
  context.setTerminatesClause(nnm);
  CompoundObjectType compoundType;
  if (fm == null)   compoundType=domainAccessHandler.getCompoundTypeFor(context.domainObjectClass);
 else {
    String classFieldName=fm.getClassFieldName();
    compoundType=MappingUtil.internalDomainAccess.get().getConcreteFieldType(classFieldName);
  }
  Class<? extends Object> pureType=fm != null ? fm.getFieldType() : context.domainObjectClass;
  if (compoundType != null) {
    context.path.add(new PathElement(pureType));
    boolean resolveDeep=true;
    if (context.recursionExitNodes.contains(nnm)) {
      resolveDeep=false;
    }
    boolean isCollection=Collection.class.isAssignableFrom(pureType);
    Collection<Object> collection=null;
    if (isCollection) {
      String classFieldName=fm.getClassFieldName();
      collection=(Collection<Object>)domainAccessHandler.createInstance(MappingUtil.internalDomainAccess.get().getConcreteFieldType(classFieldName).getType());
      compoundType=MappingUtil.internalDomainAccess.get().getFieldComponentType(classFieldName);
    }
    JcNode n=new JcNode(nnm);
    List<GrNode> resList=context.qResult.resultOf(n);
    Object domainObject=null;
    if (resList.size() > 0) {
      for (      GrNode rNode : resList) {
        if (rNode != null) {
          boolean performMapping=false;
          boolean mapProperties=true;
          domainObject=domainAccessHandler.domainState.getFrom_Id2ObjectMap(rNode.getId());
          if (domainObject == null) {
            Class<?> clazz=domainAccessHandler.findClassToInstantiateFor(rNode);
            domainObject=domainAccessHandler.createInstance(clazz);
            domainAccessHandler.domainState.add_Id2Object(domainObject,rNode.getId(),resolveDeep ? ResolutionDepth.DEEP : ResolutionDepth.SHALLOW);
            performMapping=true;
          }
 else {
            if (resolveDeep && domainAccessHandler.domainState.getResolutionDepth(domainObject) != ResolutionDepth.DEEP) {
              performMapping=true;
              mapProperties=false;
            }
          }
          if (fm == null) {
            context.domainObject=(T)domainObject;
          }
          if (performMapping) {
            ObjectMapping objectMapping=domainAccessHandler.getCompoundObjectMappingFor(compoundType,domainObject.getClass());
            Iterator<FieldMapping> it=objectMapping.fieldMappingsIterator();
            int idx=0;
            while (it.hasNext()) {
              FieldMapping fMap=it.next();
              idx++;
              if (!objectMapping.shouldPerformFieldMapping(fMap)) {
                if (fMap.needsRelation() && resolveDeep) {
                  calculateMaxClauseRepetitionNumber(context,fMap,idx);
                }
                continue;
              }
              if (fMap.needsRelation() && resolveDeep) {
                context.currentObject=null;
                PathElement pe=context.getLastPathElement();
                pe.fieldIndex=idx;
                context.clauseRepetitionNumber=context.maxClauseRepetitionNumber;
                pe.fieldName=fMap.getFieldName();
                String ndName=this.buildNodeOrRelationName(context.path,DomainAccessHandler.NodePrefix,context.clauseRepetitionNumber);
                boolean nodeIsNull=false;
                boolean needToRepeat=false;
                if (isValidNodeName(ndName,context))                 nodeIsNull=this.fillModel(context,fMap,ndName);
 else                 needToRepeat=true;
                context.alreadyTested.clear();
                while (needToRepeat && morePathsToTest(context,fMap,idx)) {
                  context.currentObject=null;
                  pe=context.getLastPathElement();
                  pe.fieldIndex=idx;
                  context.clauseRepetitionNumber=context.maxClauseRepetitionNumber;
                  pe.fieldName=fMap.getFieldName();
                  ndName=this.buildNodeOrRelationName(context.path,DomainAccessHandler.NodePrefix,context.clauseRepetitionNumber);
                  needToRepeat=false;
                  if (isValidNodeName(ndName,context))                   nodeIsNull=this.fillModel(context,fMap,ndName);
 else {
                    if (moreClausesAvailable(ndName,context))                     needToRepeat=true;
                  }
                }
                if (!nodeIsNull && context.currentObject != null) {
                  fMap.setField(domainObject,context.currentObject);
                  String rnm=this.buildNodeOrRelationName(context.path,DomainAccessHandler.RelationPrefix,context.clauseRepetitionNumber);
                  JcRelation r=new JcRelation(rnm);
                  List<GrRelation> relList=context.qResult.resultOf(r);
                  GrRelation rel=relList.get(0);
                  domainAccessHandler.domainState.add_Id2Relation(new Relation(fMap.getPropertyOrRelationName(),domainObject,context.currentObject),rel.getId());
                }
 else                 if (nodeIsNull && fMap.isCollection()) {
                  fMap.mapPropertyToField(domainObject,rNode);
                }
                context.updateMaxClauseRepetitionNumber();
              }
 else {
                if (mapProperties)                 fMap.mapPropertyToField(domainObject,rNode);
              }
            }
          }
          if (isCollection)           collection.add(domainObject);
        }
 else {
          isNullNode=true;
        }
      }
    }
    if (isCollection)     context.currentObject=collection;
 else     context.currentObject=domainObject;
    context.path.remove(context.path.size() - 1);
  }
  context.clauseRepetitionNumber=prevClauseRepetitionNumber;
  return isNullNode;
}