Program: 67354
Project: 67354
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)) {
    return cp.containerInstance();
  }
  Vector nestedRows=this.getDescriptor().buildNestedRowsFromFieldValue(fieldValue,executionSession);
  if (nestedRows == null) {
    return cp.containerInstance();
  }
  Object result=cp.containerInstance(nestedRows.size());
  for (Enumeration stream=nestedRows.elements(); stream.hasMoreElements(); ) {
    AbstractRecord nestedRow=(AbstractRecord)stream.nextElement();
    Object objectToAdd=null;
    ClassDescriptor aDescriptor=getReferenceDescriptor((DOMRecord)nestedRow);
    if (aDescriptor == null) {
      if ((getKeepAsElementPolicy() == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (getKeepAsElementPolicy() == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) {
        XMLPlatformFactory.getInstance().getXMLPlatform().namespaceQualifyFragment((Element)((DOMRecord)nestedRow).getDOM());
        objectToAdd=((DOMRecord)nestedRow).getDOM();
        if (getConverter() != null) {
          if (getConverter() instanceof XMLConverter) {
            objectToAdd=((XMLConverter)getConverter()).convertDataValueToObjectValue(objectToAdd,executionSession,((XMLRecord)nestedRow).getUnmarshaller());
          }
 else {
            objectToAdd=getConverter().convertDataValueToObjectValue(objectToAdd,executionSession);
          }
        }
      }
 else {
        NodeList children=((Element)((DOMRecord)nestedRow).getDOM()).getChildNodes();
        for (int i=0; i < children.getLength(); i++) {
          Node nextNode=children.item(i);
          if (nextNode.getNodeType() == nextNode.ELEMENT_NODE) {
            throw XMLMarshalException.noDescriptorFound(this);
          }
        }
        Element theElement=((Element)((DOMRecord)nestedRow).getDOM());
        Node textchild=theElement.getFirstChild();
        if ((textchild != null) && (textchild.getNodeType() == Node.TEXT_NODE)) {
          objectToAdd=((Text)textchild).getNodeValue();
        }
        if ((objectToAdd != null) && !objectToAdd.equals("String_Node_Str")) {
          String type=theElement.getAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
          if ((null != type) && !type.equals("String_Node_Str")) {
            XPathFragment typeFragment=new XPathFragment(type);
            String namespaceURI=((DOMRecord)nestedRow).resolveNamespacePrefix(typeFragment.getPrefix());
            typeFragment.setNamespaceURI(namespaceURI);
            QName schemaTypeQName=new QName(namespaceURI,typeFragment.getLocalName());
            Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(schemaTypeQName);
            if (theClass != null) {
              objectToAdd=((XMLConversionManager)executionSession.getDatasourcePlatform().getConversionManager()).convertObject(objectToAdd,theClass,schemaTypeQName);
            }
          }
        }
      }
    }
 else {
      if (aDescriptor.hasInheritance()) {
        Class newElementClass=aDescriptor.getInheritancePolicy().classFromRow(nestedRow,executionSession);
        if (newElementClass == null) {
          QName leafElementType=((XMLField)getField()).getLeafElementType();
          if (leafElementType != null) {
            Object indicator=aDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(leafElementType);
            if (indicator == null) {
              throw DescriptorException.missingClassForIndicatorFieldValue(leafElementType,aDescriptor.getInheritancePolicy().getDescriptor());
            }
            newElementClass=(Class)indicator;
          }
        }
        if (newElementClass != null) {
          aDescriptor=this.getReferenceDescriptor(newElementClass,executionSession);
        }
 else {
          if (Modifier.isAbstract(aDescriptor.getJavaClass().getModifiers())) {
            throw DescriptorException.missingClassIndicatorField(nestedRow,aDescriptor.getInheritancePolicy().getDescriptor());
          }
        }
      }
      objectToAdd=buildCompositeObject(aDescriptor,nestedRow,sourceQuery,joinManager);
      if (hasConverter()) {
        if (getConverter() instanceof XMLConverter) {
          objectToAdd=((XMLConverter)getConverter()).convertDataValueToObjectValue(objectToAdd,executionSession,((XMLRecord)nestedRow).getUnmarshaller());
        }
 else {
          objectToAdd=getConverter().convertDataValueToObjectValue(objectToAdd,executionSession);
        }
      }
    }
    cp.addInto(objectToAdd,result,sourceQuery.getSession());
    if (null != containerAccessor) {
      containerAccessor.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)) {
    return cp.containerInstance();
  }
  Vector nestedRows=this.getDescriptor().buildNestedRowsFromFieldValue(fieldValue,executionSession);
  if (nestedRows == null) {
    return cp.containerInstance();
  }
  Object result=cp.containerInstance(nestedRows.size());
  for (Enumeration stream=nestedRows.elements(); stream.hasMoreElements(); ) {
    AbstractRecord nestedRow=(AbstractRecord)stream.nextElement();
    Object objectToAdd=null;
    ClassDescriptor aDescriptor=getReferenceDescriptor((DOMRecord)nestedRow);
    if (aDescriptor == null) {
      if ((getKeepAsElementPolicy() == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (getKeepAsElementPolicy() == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) {
        XMLPlatformFactory.getInstance().getXMLPlatform().namespaceQualifyFragment((Element)((DOMRecord)nestedRow).getDOM());
        objectToAdd=((DOMRecord)nestedRow).getDOM();
        if (getConverter() != null) {
          if (getConverter() instanceof XMLConverter) {
            objectToAdd=((XMLConverter)getConverter()).convertDataValueToObjectValue(objectToAdd,executionSession,((XMLRecord)nestedRow).getUnmarshaller());
          }
 else {
            objectToAdd=getConverter().convertDataValueToObjectValue(objectToAdd,executionSession);
          }
        }
        objectToAdd=convertToSimpleTypeIfPresent(objectToAdd,nestedRow,executionSession);
      }
 else {
        NodeList children=((Element)((DOMRecord)nestedRow).getDOM()).getChildNodes();
        for (int i=0; i < children.getLength(); i++) {
          Node nextNode=children.item(i);
          if (nextNode.getNodeType() == nextNode.ELEMENT_NODE) {
            throw XMLMarshalException.noDescriptorFound(this);
          }
        }
        objectToAdd=convertToSimpleTypeIfPresent(objectToAdd,nestedRow,executionSession);
      }
    }
 else {
      if (aDescriptor.hasInheritance()) {
        Class newElementClass=aDescriptor.getInheritancePolicy().classFromRow(nestedRow,executionSession);
        if (newElementClass == null) {
          QName leafElementType=((XMLField)getField()).getLeafElementType();
          if (leafElementType != null) {
            Object indicator=aDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(leafElementType);
            if (indicator == null) {
              throw DescriptorException.missingClassForIndicatorFieldValue(leafElementType,aDescriptor.getInheritancePolicy().getDescriptor());
            }
            newElementClass=(Class)indicator;
          }
        }
        if (newElementClass != null) {
          aDescriptor=this.getReferenceDescriptor(newElementClass,executionSession);
        }
 else {
          if (Modifier.isAbstract(aDescriptor.getJavaClass().getModifiers())) {
            throw DescriptorException.missingClassIndicatorField(nestedRow,aDescriptor.getInheritancePolicy().getDescriptor());
          }
        }
      }
      objectToAdd=buildCompositeObject(aDescriptor,nestedRow,sourceQuery,joinManager);
      if (hasConverter()) {
        if (getConverter() instanceof XMLConverter) {
          objectToAdd=((XMLConverter)getConverter()).convertDataValueToObjectValue(objectToAdd,executionSession,((XMLRecord)nestedRow).getUnmarshaller());
        }
 else {
          objectToAdd=getConverter().convertDataValueToObjectValue(objectToAdd,executionSession);
        }
      }
    }
    cp.addInto(objectToAdd,result,sourceQuery.getSession());
    if (null != containerAccessor) {
      containerAccessor.setAttributeValueInObject(objectToAdd,((DOMRecord)nestedRow).getOwningObject());
    }
  }
  return result;
}