Program: 65755
Project: 65755
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  unmarshalRecord.removeNullCapableValue(this);
  UnmarshalRecord childRecord=unmarshalRecord.getChildRecord();
  if (null != childRecord) {
    Object childObject=childRecord.getCurrentObject();
    if (xmlAnyObjectMapping.usesXMLRoot()) {
      XMLDescriptor workingDescriptor=childRecord.getDescriptor();
      if (workingDescriptor != null) {
        String prefix=xPathFragment.getPrefix();
        if ((prefix == null) && (xPathFragment.getNamespaceURI() != null)) {
          prefix=unmarshalRecord.resolveNamespaceUri(xPathFragment.getNamespaceURI());
        }
        childObject=workingDescriptor.wrapObjectInXMLRoot(childObject,xPathFragment.getNamespaceURI(),xPathFragment.getLocalName(),prefix,false);
        workingDescriptor=null;
      }
    }
    if (xmlAnyObjectMapping.getConverter() != null) {
      childObject=xmlAnyObjectMapping.getConverter().convertDataValueToObjectValue(childObject,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    }
    unmarshalRecord.setAttributeValue(childObject,xmlAnyObjectMapping);
  }
 else {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlAnyObjectMapping.getKeepAsElementPolicy();
    if ((((keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT))) && (builder.getNodes().size() > 1)) {
      setOrAddAttributeValueForKeepAsElement(builder,xmlAnyObjectMapping,xmlAnyObjectMapping.getConverter(),unmarshalRecord,false,null);
    }
 else {
      if (xmlAnyObjectMapping.isMixedContent()) {
        endElementProcessText(unmarshalRecord,xmlAnyObjectMapping.getConverter(),xPathFragment,null);
      }
 else {
        unmarshalRecord.resetStringBuffer();
      }
    }
  }
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  unmarshalRecord.removeNullCapableValue(this);
  UnmarshalRecord childRecord=unmarshalRecord.getChildRecord();
  if (null != childRecord) {
    Object childObject=childRecord.getCurrentObject();
    if (xmlAnyObjectMapping.usesXMLRoot()) {
      XMLDescriptor workingDescriptor=childRecord.getDescriptor();
      if (workingDescriptor != null) {
        String prefix=xPathFragment.getPrefix();
        if ((prefix == null) && (xPathFragment.getNamespaceURI() != null)) {
          prefix=unmarshalRecord.resolveNamespaceUri(xPathFragment.getNamespaceURI());
        }
        childObject=workingDescriptor.wrapObjectInXMLRoot(childObject,xPathFragment.getNamespaceURI(),xPathFragment.getLocalName(),prefix,false,unmarshalRecord.getUnmarshaller().isNamespaceAware());
        workingDescriptor=null;
      }
    }
    if (xmlAnyObjectMapping.getConverter() != null) {
      childObject=xmlAnyObjectMapping.getConverter().convertDataValueToObjectValue(childObject,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    }
    unmarshalRecord.setAttributeValue(childObject,xmlAnyObjectMapping);
  }
 else {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlAnyObjectMapping.getKeepAsElementPolicy();
    if ((((keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT))) && (builder.getNodes().size() > 1)) {
      setOrAddAttributeValueForKeepAsElement(builder,xmlAnyObjectMapping,xmlAnyObjectMapping.getConverter(),unmarshalRecord,false,null);
    }
 else {
      if (xmlAnyObjectMapping.isMixedContent()) {
        endElementProcessText(unmarshalRecord,xmlAnyObjectMapping.getConverter(),xPathFragment,null);
      }
 else {
        unmarshalRecord.resetStringBuffer();
      }
    }
  }
}