Program: 63674
Project: 63674
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  UnmarshalRecord childRecord=unmarshalRecord.getChildRecord();
  if (null != childRecord) {
    if (!xmlAnyCollectionMapping.usesXMLRoot()) {
      Object objectValue=childRecord.getCurrentObject();
      objectValue=xmlAnyCollectionMapping.convertDataValueToObjectValue(objectValue,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
      unmarshalRecord.addAttributeValue(this,objectValue);
    }
 else {
      Object childObject=childRecord.getCurrentObject();
      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());
        childObject=xmlAnyCollectionMapping.convertDataValueToObjectValue(childObject,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
        unmarshalRecord.addAttributeValue(this,childObject);
      }
    }
    unmarshalRecord.setChildRecord(null);
  }
 else {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    if (xmlAnyCollectionMapping.isMixedContent() && unmarshalRecord.getTextWrapperFragment() != null && unmarshalRecord.getTextWrapperFragment().equals(xPathFragment)) {
      endElementProcessText(unmarshalRecord,xmlAnyCollectionMapping,xPathFragment,null);
      return;
    }
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlAnyCollectionMapping.getKeepAsElementPolicy();
    if (null != keepAsElementPolicy && (keepAsElementPolicy.isKeepUnknownAsElement() || keepAsElementPolicy.isKeepAllAsElement()) && builder.getNodes().size() > 1) {
      setOrAddAttributeValueForKeepAsElement(builder,xmlAnyCollectionMapping,xmlAnyCollectionMapping,unmarshalRecord,true,null);
    }
 else {
      if (xmlAnyCollectionMapping.isMixedContent()) {
        endElementProcessText(unmarshalRecord,xmlAnyCollectionMapping,xPathFragment,null);
      }
 else {
        unmarshalRecord.resetStringBuffer();
      }
    }
  }
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Object collection){
  UnmarshalRecord childRecord=unmarshalRecord.getChildRecord();
  if (null != childRecord) {
    if (!xmlAnyCollectionMapping.usesXMLRoot()) {
      Object objectValue=childRecord.getCurrentObject();
      objectValue=xmlAnyCollectionMapping.convertDataValueToObjectValue(objectValue,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
      unmarshalRecord.addAttributeValue(this,objectValue);
    }
 else {
      Object childObject=childRecord.getCurrentObject();
      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());
        childObject=xmlAnyCollectionMapping.convertDataValueToObjectValue(childObject,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
        unmarshalRecord.addAttributeValue(this,childObject);
      }
    }
    unmarshalRecord.setChildRecord(null);
  }
 else {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    if (xmlAnyCollectionMapping.isMixedContent() && unmarshalRecord.getTextWrapperFragment() != null && unmarshalRecord.getTextWrapperFragment().equals(xPathFragment)) {
      endElementProcessText(unmarshalRecord,xmlAnyCollectionMapping,xPathFragment,null);
      return;
    }
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlAnyCollectionMapping.getKeepAsElementPolicy();
    if (null != keepAsElementPolicy && (keepAsElementPolicy.isKeepUnknownAsElement() || keepAsElementPolicy.isKeepAllAsElement()) && builder.getNodes().size() > 1) {
      setOrAddAttributeValueForKeepAsElement(builder,xmlAnyCollectionMapping,xmlAnyCollectionMapping,unmarshalRecord,true,collection);
    }
 else {
      if (xmlAnyCollectionMapping.isMixedContent()) {
        endElementProcessText(unmarshalRecord,xmlAnyCollectionMapping,xPathFragment,null);
      }
 else {
        unmarshalRecord.resetStringBuffer();
      }
    }
  }
}