Program: 65514
Project: 65514
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  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.getConverter(),xPathFragment,null);
          return;
        }
      }
      if (builder.getDocument() != null) {
        setOrAddAttributeValueForKeepAsElement(builder,(XMLMapping)xmlCompositeObjectMapping,(XMLConverter)xmlCompositeObjectMapping.getConverter(),unmarshalRecord,false,null);
        return;
      }
    }
 else {
      endElementProcessText(unmarshalRecord,xmlCompositeObjectMapping.getConverter(),xPathFragment,null);
      return;
    }
  }
 else {
    Object object=unmarshalRecord.getChildRecord().getCurrentObject();
    if (xmlCompositeObjectMapping.getConverter() != null) {
      Converter converter=xmlCompositeObjectMapping.getConverter();
      if (converter instanceof XMLConverter) {
        object=((XMLConverter)converter).convertDataValueToObjectValue(object,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
      }
 else {
        object=converter.convertDataValueToObjectValue(object,unmarshalRecord.getSession());
      }
    }
    unmarshalRecord.setAttributeValue(object,xmlCompositeObjectMapping);
    XMLInverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
    if (null != inverseReferenceMapping) {
      if (inverseReferenceMapping.getContainerPolicy() == null) {
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,unmarshalRecord.getCurrentObject());
      }
 else {
        Object backpointerContainer=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
        if (backpointerContainer == null) {
          backpointerContainer=inverseReferenceMapping.getContainerPolicy().containerInstance();
          inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,backpointerContainer);
        }
        inverseReferenceMapping.getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
      }
    }
    unmarshalRecord.setChildRecord(null);
  }
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  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.getConverter(),xPathFragment,null);
          return;
        }
      }
      if (builder.getDocument() != null) {
        setOrAddAttributeValueForKeepAsElement(builder,(XMLMapping)xmlCompositeObjectMapping,(XMLConverter)xmlCompositeObjectMapping.getConverter(),unmarshalRecord,false,null);
        return;
      }
    }
 else {
      endElementProcessText(unmarshalRecord,xmlCompositeObjectMapping.getConverter(),xPathFragment,null);
      return;
    }
  }
 else {
    Object object=unmarshalRecord.getChildRecord().getCurrentObject();
    setAttributeValue(object,unmarshalRecord);
    unmarshalRecord.setChildRecord(null);
  }
}