Program: 66164
Project: 66164
Buggy source:
public Object valueFromRow(AbstractRecord row,JoinedAttributeManager joinManager,ObjectBuildingQuery sourceQuery,AbstractSession executionSession) throws DatabaseException {
  ContainerPolicy cp=this.getContainerPolicy();
  Object fieldValue=row.getValues(this.getField());
  if ((fieldValue == null) || (fieldValue instanceof String)) {
    if (reuseContainer) {
      Object currentObject=((XMLRecord)row).getCurrentObject();
      Object container=getAttributeAccessor().getAttributeValueFromObject(currentObject);
      return container != null ? container : cp.containerInstance();
    }
 else {
      return cp.containerInstance();
    }
  }
  Vector nestedRows=this.getDescriptor().buildNestedRowsFromFieldValue(fieldValue,executionSession);
  if (nestedRows == null) {
    if (reuseContainer) {
      Object currentObject=((XMLRecord)row).getCurrentObject();
      Object container=getAttributeAccessor().getAttributeValueFromObject(currentObject);
      return container != null ? container : cp.containerInstance();
    }
 else {
      return cp.containerInstance();
    }
  }
  Object result=null;
  if (reuseContainer) {
    Object currentObject=((XMLRecord)row).getCurrentObject();
    Object container=getAttributeAccessor().getAttributeValueFromObject(currentObject);
    result=container != null ? container : cp.containerInstance();
  }
 else {
    result=cp.containerInstance(nestedRows.size());
  }
  for (Enumeration stream=nestedRows.elements(); stream.hasMoreElements(); ) {
    AbstractRecord nestedRow=(AbstractRecord)stream.nextElement();
    Object objectToAdd=buildObjectFromNestedRow(nestedRow,joinManager,sourceQuery,executionSession);
    cp.addInto(objectToAdd,result,sourceQuery.getSession());
    if (null != getContainerAccessor()) {
      Object currentObject=((XMLRecord)row).getCurrentObject();
      if (this.inverseReferenceMapping.getContainerPolicy() == null) {
        getContainerAccessor().setAttributeValueInObject(objectToAdd,currentObject);
      }
 else {
        Object backpointerContainer=getContainerAccessor().getAttributeValueFromObject(objectToAdd);
        if (backpointerContainer == null) {
          backpointerContainer=this.inverseReferenceMapping.getContainerPolicy().containerInstance();
          getContainerAccessor().setAttributeValueInObject(objectToAdd,backpointerContainer);
        }
        this.inverseReferenceMapping.getContainerPolicy().addInto(currentObject,backpointerContainer,executionSession);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
public Object valueFromRow(AbstractRecord row,JoinedAttributeManager joinManager,ObjectBuildingQuery sourceQuery,AbstractSession executionSession) throws DatabaseException {
  ContainerPolicy cp=this.getContainerPolicy();
  Object fieldValue=row.getValues(this.getField());
  if ((fieldValue == null) || (fieldValue instanceof String)) {
    if (reuseContainer) {
      Object currentObject=((XMLRecord)row).getCurrentObject();
      Object container=getAttributeAccessor().getAttributeValueFromObject(currentObject);
      return container != null ? container : cp.containerInstance();
    }
 else {
      return cp.containerInstance();
    }
  }
  Vector nestedRows=this.getDescriptor().buildNestedRowsFromFieldValue(fieldValue,executionSession);
  if (nestedRows == null) {
    if (reuseContainer) {
      Object currentObject=((XMLRecord)row).getCurrentObject();
      Object container=getAttributeAccessor().getAttributeValueFromObject(currentObject);
      return container != null ? container : cp.containerInstance();
    }
 else {
      return cp.containerInstance();
    }
  }
  Object result=null;
  if (reuseContainer) {
    Object currentObject=((XMLRecord)row).getCurrentObject();
    Object container=getAttributeAccessor().getAttributeValueFromObject(currentObject);
    result=container != null ? container : cp.containerInstance();
  }
 else {
    result=cp.containerInstance(nestedRows.size());
  }
  for (Enumeration stream=nestedRows.elements(); stream.hasMoreElements(); ) {
    XMLRecord nestedRow=(XMLRecord)stream.nextElement();
    Object objectToAdd;
    if (getNullPolicy().valueIsNull((Element)nestedRow.getDOM())) {
      objectToAdd=null;
    }
 else {
      objectToAdd=buildObjectFromNestedRow(nestedRow,joinManager,sourceQuery,executionSession);
    }
    cp.addInto(objectToAdd,result,sourceQuery.getSession());
    if (null != getContainerAccessor()) {
      Object currentObject=((XMLRecord)row).getCurrentObject();
      if (this.inverseReferenceMapping.getContainerPolicy() == null) {
        getContainerAccessor().setAttributeValueInObject(objectToAdd,currentObject);
      }
 else {
        Object backpointerContainer=getContainerAccessor().getAttributeValueFromObject(objectToAdd);
        if (backpointerContainer == null) {
          backpointerContainer=this.inverseReferenceMapping.getContainerPolicy().containerInstance();
          getContainerAccessor().setAttributeValueInObject(objectToAdd,backpointerContainer);
        }
        this.inverseReferenceMapping.getContainerPolicy().addInto(currentObject,backpointerContainer,executionSession);
      }
    }
  }
  return result;
}