Program: 64137
Project: 64137
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()) {
      Descriptor 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.isNamespaceAware(),unmarshalRecord.getUnmarshaller());
        workingDescriptor=null;
      }
    }
    childObject=xmlAnyObjectMapping.convertDataValueToObjectValue(childObject,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    unmarshalRecord.setAttributeValue(childObject,xmlAnyObjectMapping);
  }
 else {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlAnyObjectMapping.getKeepAsElementPolicy();
    if (null != keepAsElementPolicy && (keepAsElementPolicy.isKeepUnknownAsElement() || keepAsElementPolicy.isKeepAllAsElement()) && builder.getNodes().size() > 1) {
      setOrAddAttributeValueForKeepAsElement(builder,xmlAnyObjectMapping,xmlAnyObjectMapping,unmarshalRecord,false,null);
    }
 else {
      if (xmlAnyObjectMapping.isMixedContent()) {
        endElementProcessText(unmarshalRecord,xmlAnyObjectMapping,xPathFragment,null);
      }
 else {
        unmarshalRecord.resetStringBuffer();
      }
    }
  }
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  UnmarshalRecord childRecord=unmarshalRecord.getChildRecord();
  if (null != childRecord) {
    Object childObject=childRecord.getCurrentObject();
    if (xmlAnyObjectMapping.usesXMLRoot()) {
      Descriptor 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.isNamespaceAware(),unmarshalRecord.getUnmarshaller());
        workingDescriptor=null;
      }
    }
    childObject=xmlAnyObjectMapping.convertDataValueToObjectValue(childObject,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    unmarshalRecord.setAttributeValue(childObject,xmlAnyObjectMapping);
  }
 else {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlAnyObjectMapping.getKeepAsElementPolicy();
    if (null != keepAsElementPolicy && (keepAsElementPolicy.isKeepUnknownAsElement() || keepAsElementPolicy.isKeepAllAsElement()) && builder.getNodes().size() > 1) {
      setOrAddAttributeValueForKeepAsElement(builder,xmlAnyObjectMapping,xmlAnyObjectMapping,unmarshalRecord,false,null);
    }
 else {
      if (xmlAnyObjectMapping.isMixedContent()) {
        endElementProcessText(unmarshalRecord,xmlAnyObjectMapping,xPathFragment,null);
      }
 else {
        unmarshalRecord.resetStringBuffer();
      }
    }
  }
}