Program: 63731
Project: 63731
Buggy source:
public void endSelfNodeValue(UnmarshalRecord unmarshalRecord,UnmarshalRecord selfRecord,Attributes attributes){
  if (xmlCompositeObjectMapping.getNullPolicy().valueIsNull(attributes)) {
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),null);
    return;
  }
  unmarshalRecord.removeNullCapableValue(this);
  if (unmarshalRecord.getFragmentBuilder().getDocument() != null) {
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeObjectMapping.getKeepAsElementPolicy();
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    if ((((keepAsElementPolicy.isKeepUnknownAsElement()) || (keepAsElementPolicy.isKeepAllAsElement()))) && (builder.getNodes().size() != 0)) {
      if (unmarshalRecord.getTypeQName() != null) {
        Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(unmarshalRecord.getTypeQName());
        if (theClass != null) {
          endElementProcessText(unmarshalRecord,xmlCompositeObjectMapping,null,null);
          return;
        }
      }
      Element element=(Element)builder.getNodes().remove(builder.getNodes().size() - 1);
      String xsiType=null;
      if (null != element) {
        if (unmarshalRecord.isNamespaceAware()) {
          xsiType=element.getAttributeNS(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_TYPE_ATTRIBUTE);
        }
 else {
          xsiType=element.getAttribute(Constants.SCHEMA_TYPE_ATTRIBUTE);
        }
      }
      if (null != xsiType) {
        xsiType=xsiType.trim();
        Object value=element;
        String namespace=null;
        int colonIndex=xsiType.indexOf(unmarshalRecord.getNamespaceSeparator());
        if (colonIndex > -1) {
          String prefix=xsiType.substring(0,colonIndex);
          namespace=unmarshalRecord.resolveNamespacePrefix(prefix);
          if (null == namespace) {
            namespace=XMLPlatformFactory.getInstance().getXMLPlatform().resolveNamespacePrefix(element,prefix);
          }
          String name=xsiType.substring(colonIndex + 1);
          QName qName=new QName(namespace,xsiType.substring(colonIndex + 1));
          Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(qName);
          if (theClass != null) {
            value=((ConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(element.getTextContent(),theClass,qName);
          }
        }
 else {
          if (!unmarshalRecord.isNamespaceAware()) {
            QName qName=new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI,xsiType);
            Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(qName);
            if (theClass != null) {
              value=((ConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(element.getTextContent(),theClass,qName);
            }
          }
        }
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),value);
      }
 else {
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),element);
      }
    }
  }
 else {
    Object valueToSet=selfRecord.getCurrentObject();
    valueToSet=xmlCompositeObjectMapping.convertDataValueToObjectValue(valueToSet,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),valueToSet);
    InverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
    if (null != inverseReferenceMapping) {
      inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(valueToSet,unmarshalRecord.getCurrentObject());
    }
  }
}

Fixed version (ground truth):
public void endSelfNodeValue(UnmarshalRecord unmarshalRecord,UnmarshalRecord selfRecord,Attributes attributes){
  if (xmlCompositeObjectMapping.getNullPolicy().valueIsNull(attributes)) {
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),null);
    return;
  }
  unmarshalRecord.removeNullCapableValue(this);
  if (unmarshalRecord.getFragmentBuilder().getDocument() != null) {
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeObjectMapping.getKeepAsElementPolicy();
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    if ((((keepAsElementPolicy.isKeepUnknownAsElement()) || (keepAsElementPolicy.isKeepAllAsElement()))) && (builder.getNodes().size() != 0)) {
      if (unmarshalRecord.getTypeQName() != null) {
        Class theClass=unmarshalRecord.getConversionManager().javaType(unmarshalRecord.getTypeQName());
        if (theClass != null) {
          endElementProcessText(unmarshalRecord,xmlCompositeObjectMapping,null,null);
          return;
        }
      }
      Element element=(Element)builder.getNodes().remove(builder.getNodes().size() - 1);
      String xsiType=null;
      if (null != element) {
        if (unmarshalRecord.isNamespaceAware()) {
          xsiType=element.getAttributeNS(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_TYPE_ATTRIBUTE);
        }
 else {
          xsiType=element.getAttribute(Constants.SCHEMA_TYPE_ATTRIBUTE);
        }
      }
      if (null != xsiType) {
        xsiType=xsiType.trim();
        Object value=element;
        String namespace=null;
        int colonIndex=xsiType.indexOf(unmarshalRecord.getNamespaceSeparator());
        if (colonIndex > -1) {
          String prefix=xsiType.substring(0,colonIndex);
          namespace=unmarshalRecord.resolveNamespacePrefix(prefix);
          if (null == namespace) {
            namespace=XMLPlatformFactory.getInstance().getXMLPlatform().resolveNamespacePrefix(element,prefix);
          }
          String name=xsiType.substring(colonIndex + 1);
          QName qName=new QName(namespace,xsiType.substring(colonIndex + 1));
          ConversionManager conversionManager=unmarshalRecord.getConversionManager();
          Class theClass=conversionManager.javaType(qName);
          if (theClass != null) {
            value=conversionManager.convertObject(element.getTextContent(),theClass,qName);
          }
        }
 else {
          if (!unmarshalRecord.isNamespaceAware()) {
            QName qName=new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI,xsiType);
            ConversionManager conversionManager=unmarshalRecord.getConversionManager();
            Class theClass=conversionManager.javaType(qName);
            if (theClass != null) {
              value=conversionManager.convertObject(element.getTextContent(),theClass,qName);
            }
          }
        }
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),value);
      }
 else {
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),element);
      }
    }
  }
 else {
    Object valueToSet=selfRecord.getCurrentObject();
    valueToSet=xmlCompositeObjectMapping.convertDataValueToObjectValue(valueToSet,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),valueToSet);
    InverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
    if (null != inverseReferenceMapping) {
      inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(valueToSet,unmarshalRecord.getCurrentObject());
    }
  }
}