Program: 80463
Project: 80463
Buggy source:
private void buildStep(int tmpNodeIdx,boolean listOrArray,CloneInfo cloneInfo,boolean forward){
  FieldMapping fm=this.fieldMappings.get(this.fmIndex);
  Relation matchRel=matchNode.relation().type(fm.getPropertyOrRelationName());
  if (forward)   matchRel=matchRel.out();
 else   matchRel=matchRel.in();
  if (this.step.getMinDistance() != 1)   matchRel=matchRel.minHops(this.step.getMinDistance());
  if (this.step.getMaxDistance() != 1) {
    if (this.step.getMaxDistance() == -1)     matchRel=matchRel.maxHopsUnbound();
 else     matchRel=matchRel.maxHops(this.step.getMaxDistance());
  }
  Class<?> typ;
  CompoundObjectType cType=null;
  if (forward) {
    if (listOrArray) {
      cType=getMappingInfo().getInternalDomainAccess().getFieldComponentType(fm.getClassFieldName());
    }
 else {
      cType=getMappingInfo().getInternalDomainAccess().getConcreteFieldType(fm.getClassFieldName());
    }
    typ=cType.getType();
  }
 else {
    typ=fm.getField().getDeclaringClass();
  }
  boolean isList=typ.equals(Collection.class) || typ.equals(Array.class);
  Step nextStep=null;
  int nextStepIndex=this.stepIndex;
  List<Class<?>> types;
  if (isList) {
    if (forward) {
      nextStep=this.step.createStep(this.step.getDirection(),getMappingInfo().getObjectMappingFor(typ).fieldMappingsIterator().next().getPropertyOrRelationName());
    }
 else {
      nextStep=this.step.createStep(this.step.getDirection(),this.step.getAttributeName());
    }
    types=new ArrayList<Class<?>>();
    types.add(typ);
  }
 else {
    nextStepIndex++;
    if (nextStepIndex <= this.traversalExpression.getSteps().size() - 1)     nextStep=this.traversalExpression.getSteps().get(nextStepIndex);
    if (forward)     types=cType.getTypes(true);
 else     types=getMappingInfo().getCompoundTypesFor(typ);
  }
  if (nextStep == null) {
    if (isValidEndNodeType(types)) {
      this.endNode=new JcNode(this.originalEndNodeName.concat(tmpNodePostPrefix).concat(String.valueOf(tmpNodeIdx)));
      StepClause first=this.getFirst();
      if (first.jcPath != null) {
        String npm=ValueAccess.getName(first.jcPath).concat(tmpNodePostPrefix).concat(String.valueOf(tmpNodeIdx));
        ValueAccess.setName(npm,first.jcPath);
      }
      this.matchNode=matchRel.node(this.endNode).label(this.endNodeLabel);
    }
 else     this.matchNode=null;
  }
 else {
    this.matchNode=matchRel.node();
    if (cloneInfo != null)     this.buildNextClone(tmpNodeIdx,types,isList,cloneInfo);
 else     this.buildNext(tmpNodeIdx,types,isList,nextStep,nextStepIndex);
  }
}

Fixed version (ground truth):
private void buildStep(int tmpNodeIdx,boolean listOrArray,CloneInfo cloneInfo,boolean forward){
  FieldMapping fm=this.fieldMappings.get(this.fmIndex);
  Relation matchRel=matchNode.relation().type(fm.getPropertyOrRelationName());
  if (forward)   matchRel=matchRel.out();
 else   matchRel=matchRel.in();
  if (this.step.getMinDistance() != 1)   matchRel=matchRel.minHops(this.step.getMinDistance());
  if (this.step.getMaxDistance() != 1) {
    if (this.step.getMaxDistance() == -1)     matchRel=matchRel.maxHopsUnbound();
 else     matchRel=matchRel.maxHops(this.step.getMaxDistance());
  }
  Class<?> typ;
  CompoundObjectType cType=null;
  if (forward) {
    if (listOrArray) {
      cType=getMappingInfo().getInternalDomainAccess().getFieldComponentType(fm.getClassFieldName());
    }
 else {
      cType=getMappingInfo().getInternalDomainAccess().getConcreteFieldType(fm.getClassFieldName());
    }
    if (cType != null)     typ=cType.getType();
 else     typ=fm.getFieldType();
  }
 else {
    typ=fm.getField().getDeclaringClass();
  }
  boolean isList=typ.equals(Collection.class) || typ.equals(Array.class);
  Step nextStep=null;
  int nextStepIndex=this.stepIndex;
  List<Class<?>> types;
  if (isList) {
    if (forward) {
      nextStep=this.step.createStep(this.step.getDirection(),getMappingInfo().getObjectMappingFor(typ).fieldMappingsIterator().next().getPropertyOrRelationName());
    }
 else {
      nextStep=this.step.createStep(this.step.getDirection(),this.step.getAttributeName());
    }
    types=new ArrayList<Class<?>>();
    types.add(typ);
  }
 else {
    nextStepIndex++;
    if (nextStepIndex <= this.traversalExpression.getSteps().size() - 1)     nextStep=this.traversalExpression.getSteps().get(nextStepIndex);
    if (forward) {
      if (cType != null)       types=cType.getTypes(true);
 else       if (CompoundObjectType.isConcrete(typ)) {
        types=new ArrayList<Class<?>>();
        types.add(typ);
      }
 else       types=new ArrayList<Class<?>>();
    }
 else     types=getMappingInfo().getCompoundTypesFor(typ);
  }
  if (nextStep == null) {
    if (isValidEndNodeType(types)) {
      this.endNode=new JcNode(this.originalEndNodeName.concat(tmpNodePostPrefix).concat(String.valueOf(tmpNodeIdx)));
      StepClause first=this.getFirst();
      if (first.jcPath != null) {
        String npm=ValueAccess.getName(first.jcPath).concat(tmpNodePostPrefix).concat(String.valueOf(tmpNodeIdx));
        ValueAccess.setName(npm,first.jcPath);
      }
      this.matchNode=matchRel.node(this.endNode).label(this.endNodeLabel);
    }
 else     this.matchNode=null;
  }
 else {
    this.matchNode=matchRel.node();
    if (cloneInfo != null)     this.buildNextClone(tmpNodeIdx,types,isList,cloneInfo);
 else     this.buildNext(tmpNodeIdx,types,isList,nextStep,nextStepIndex);
  }
}