Program: 66515
Project: 66515
Buggy source:
public void endSelfNodeValue(UnmarshalRecord unmarshalRecord,Attributes attributes){
  if (xmlCompositeObjectMapping.getNullPolicy().valueIsNull(attributes)) {
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),null);
    return;
  }
  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.getConverter(),null,null);
          return;
        }
      }
      Element element=(Element)builder.getNodes().remove(builder.getNodes().size() - 1);
      String xsiType=null;
      if (null != element) {
        xsiType=element.getAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
      }
      if (null != xsiType) {
        xsiType=xsiType.trim();
        Object value=element;
        String namespace=null;
        int colonIndex=xsiType.indexOf(XMLConstants.COLON);
        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);
          }
        }
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),value);
      }
 else {
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),element);
      }
    }
  }
 else {
    Object valueToSet=unmarshalRecord.getChildRecord().getCurrentObject();
    if (xmlCompositeObjectMapping.getConverter() != null) {
      Converter converter=xmlCompositeObjectMapping.getConverter();
      if (converter instanceof XMLConverter) {
        valueToSet=((XMLConverter)converter).convertDataValueToObjectValue(valueToSet,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
      }
 else {
        valueToSet=converter.convertDataValueToObjectValue(valueToSet,unmarshalRecord.getSession());
      }
    }
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),valueToSet);
    if (xmlCompositeObjectMapping.getInverseReferenceMapping() != null) {
      xmlCompositeObjectMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(unmarshalRecord.getCurrentObject(),valueToSet);
    }
  }
}

Fixed version (ground truth):
public void endSelfNodeValue(UnmarshalRecord unmarshalRecord,UnmarshalRecord selfRecord,Attributes attributes){
  if (xmlCompositeObjectMapping.getNullPolicy().valueIsNull(attributes)) {
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),null);
    return;
  }
  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.getConverter(),null,null);
          return;
        }
      }
      Element element=(Element)builder.getNodes().remove(builder.getNodes().size() - 1);
      String xsiType=null;
      if (null != element) {
        xsiType=element.getAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL,XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
      }
      if (null != xsiType) {
        xsiType=xsiType.trim();
        Object value=element;
        String namespace=null;
        int colonIndex=xsiType.indexOf(XMLConstants.COLON);
        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);
          }
        }
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),value);
      }
 else {
        xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),element);
      }
    }
  }
 else {
    Object valueToSet=selfRecord.getCurrentObject();
    if (xmlCompositeObjectMapping.getConverter() != null) {
      Converter converter=xmlCompositeObjectMapping.getConverter();
      if (converter instanceof XMLConverter) {
        valueToSet=((XMLConverter)converter).convertDataValueToObjectValue(valueToSet,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
      }
 else {
        valueToSet=converter.convertDataValueToObjectValue(valueToSet,unmarshalRecord.getSession());
      }
    }
    xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(),valueToSet);
    if (xmlCompositeObjectMapping.getInverseReferenceMapping() != null) {
      xmlCompositeObjectMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(unmarshalRecord.getCurrentObject(),valueToSet);
    }
  }
}