Program: 65267
Project: 65267
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.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();
    Converter converter=xmlCompositeObjectMapping.getConverter();
    if (null != converter) {
      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);
    XMLInverseReferenceMapping 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 == 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) {
        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();
    Converter converter=xmlCompositeObjectMapping.getConverter();
    if (null != converter) {
      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);
    XMLInverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
    if (null != inverseReferenceMapping) {
      inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(valueToSet,unmarshalRecord.getCurrentObject());
    }
  }
}