Program: 66828
Project: 66828
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()) {
      getContainerAccessor().setAttributeValueInObject(objectToAdd,((DOMRecord)nestedRow).getOwningObject());
    }
  }
  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(); ) {
    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.bidirectionalPolicy.getBidirectionalTargetContainerPolicy() == null) {
        getContainerAccessor().setAttributeValueInObject(objectToAdd,currentObject);
      }
 else {
        Object backpointerContainer=getContainerAccessor().getAttributeValueFromObject(objectToAdd);
        if (backpointerContainer == null) {
          backpointerContainer=bidirectionalPolicy.getBidirectionalTargetContainerPolicy().containerInstance();
          getContainerAccessor().setAttributeValueInObject(objectToAdd,backpointerContainer);
        }
        bidirectionalPolicy.getBidirectionalTargetContainerPolicy().addInto(currentObject,backpointerContainer,executionSession);
      }
    }
  }
  return result;
}