Program: 64481
Project: 64481
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  if (unmarshalRecord.isNil() && xmlCompositeObjectMapping.getNullPolicy().isNullRepresentedByXsiNil()) {
    unmarshalRecord.resetStringBuffer();
    return;
  }
  if (null == unmarshalRecord.getChildRecord()) {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeObjectMapping.getKeepAsElementPolicy();
    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,xPathFragment,null);
          return;
        }
      }
      if (builder.getDocument() != null) {
        setOrAddAttributeValueForKeepAsElement(builder,xmlCompositeObjectMapping,xmlCompositeObjectMapping,unmarshalRecord,false,null);
        return;
      }
    }
 else {
      endElementProcessText(unmarshalRecord,xmlCompositeObjectMapping,xPathFragment,null);
      return;
    }
  }
 else {
    Object object=unmarshalRecord.getChildRecord().getCurrentObject();
    setAttributeValue(object,unmarshalRecord);
    unmarshalRecord.setChildRecord(null);
  }
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  if (unmarshalRecord.isNil() && xmlCompositeObjectMapping.getNullPolicy().isNullRepresentedByXsiNil()) {
    unmarshalRecord.resetStringBuffer();
    return;
  }
  if (null == unmarshalRecord.getChildRecord()) {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeObjectMapping.getKeepAsElementPolicy();
    if (null != keepAsElementPolicy && (keepAsElementPolicy.isKeepUnknownAsElement() || keepAsElementPolicy.isKeepAllAsElement()) && 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,xPathFragment,null);
          return;
        }
      }
      if (builder.getDocument() != null) {
        setOrAddAttributeValueForKeepAsElement(builder,xmlCompositeObjectMapping,xmlCompositeObjectMapping,unmarshalRecord,false,null);
        return;
      }
    }
 else {
      endElementProcessText(unmarshalRecord,xmlCompositeObjectMapping,xPathFragment,null);
      return;
    }
  }
 else {
    Object object=unmarshalRecord.getChildRecord().getCurrentObject();
    setAttributeValue(object,unmarshalRecord);
    unmarshalRecord.setChildRecord(null);
  }
}