Program: 80475
Project: 80475
Buggy source:
private void buildStep(int tmpNodeIdx,boolean listOrArray,CloneInfo cloneInfo,boolean forward){
  FieldMapping fm;
  if (this.fieldMappings != null && !forward)   fm=this.fieldMappings.get(this.fmIndex);
 else   fm=this.fieldMapping;
  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(this.fieldMapping.getClassFieldName());
    }
 else {
      cType=getMappingInfo().getInternalDomainAccess().getConcreteFieldType(this.fieldMapping.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());
    }
    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);
  }
}