Program: 64483
Project: 64483
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 == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT))) && (builder.getNodes().size() != 0)) {
      if (unmarshalRecord.getTypeQName() != null) {
        Class theClass=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).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(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
        }
 else {
          xsiType=element.getAttribute(XMLConstants.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=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(element.getTextContent(),theClass,qName);
          }
        }
 else {
          if (!unmarshalRecord.isNamespaceAware()) {
            QName qName=new QName(XMLConstants.SCHEMA_URL,xsiType);
            Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(qName);
            if (theClass != null) {
              value=((XMLConversionManager)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=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).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(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
        }
 else {
          xsiType=element.getAttribute(XMLConstants.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=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(element.getTextContent(),theClass,qName);
          }
        }
 else {
          if (!unmarshalRecord.isNamespaceAware()) {
            QName qName=new QName(XMLConstants.SCHEMA_URL,xsiType);
            Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(qName);
            if (theClass != null) {
              value=((XMLConversionManager)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());
    }
  }
}