Program: 66826
Project: 66826
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Object collection){
  if (null == unmarshalRecord.getChildRecord()) {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeCollectionMapping.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,xmlCompositeCollectionMapping.getConverter(),xPathFragment,collection);
          return;
        }
      }
      if (builder.getDocument() != null) {
        setOrAddAttributeValueForKeepAsElement(builder,(XMLMapping)xmlCompositeCollectionMapping,(XMLConverter)xmlCompositeCollectionMapping.getConverter(),unmarshalRecord,true,collection);
        return;
      }
    }
 else {
      endElementProcessText(unmarshalRecord,xmlCompositeCollectionMapping.getConverter(),xPathFragment,collection);
      return;
    }
    return;
  }
  Object objectValue=unmarshalRecord.getChildRecord().getCurrentObject();
  if (xmlCompositeCollectionMapping.hasConverter()) {
    Converter converter=xmlCompositeCollectionMapping.getConverter();
    if (converter instanceof XMLConverter) {
      objectValue=((XMLConverter)converter).convertDataValueToObjectValue(objectValue,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    }
 else {
      objectValue=converter.convertObjectValueToDataValue(objectValue,unmarshalRecord.getSession());
    }
  }
  unmarshalRecord.addAttributeValue(this,objectValue,collection);
  if (xmlCompositeCollectionMapping.getContainerAccessor() != null) {
    xmlCompositeCollectionMapping.getContainerAccessor().setAttributeValueInObject(objectValue,unmarshalRecord.getCurrentObject());
  }
  unmarshalRecord.setChildRecord(null);
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Object collection){
  if (null == unmarshalRecord.getChildRecord()) {
    SAXFragmentBuilder builder=unmarshalRecord.getFragmentBuilder();
    UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeCollectionMapping.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,xmlCompositeCollectionMapping.getConverter(),xPathFragment,collection);
          return;
        }
      }
      if (builder.getDocument() != null) {
        setOrAddAttributeValueForKeepAsElement(builder,(XMLMapping)xmlCompositeCollectionMapping,(XMLConverter)xmlCompositeCollectionMapping.getConverter(),unmarshalRecord,true,collection);
        return;
      }
    }
 else {
      endElementProcessText(unmarshalRecord,xmlCompositeCollectionMapping.getConverter(),xPathFragment,collection);
      return;
    }
    return;
  }
  Object objectValue=unmarshalRecord.getChildRecord().getCurrentObject();
  if (xmlCompositeCollectionMapping.hasConverter()) {
    Converter converter=xmlCompositeCollectionMapping.getConverter();
    if (converter instanceof XMLConverter) {
      objectValue=((XMLConverter)converter).convertDataValueToObjectValue(objectValue,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    }
 else {
      objectValue=converter.convertObjectValueToDataValue(objectValue,unmarshalRecord.getSession());
    }
  }
  unmarshalRecord.addAttributeValue(this,objectValue,collection);
  if (xmlCompositeCollectionMapping.getContainerAccessor() != null) {
    if (xmlCompositeCollectionMapping.getBidirectionalPolicy().getBidirectionalTargetContainerPolicy() == null) {
      xmlCompositeCollectionMapping.getContainerAccessor().setAttributeValueInObject(objectValue,unmarshalRecord.getCurrentObject());
    }
 else {
      Object backpointerContainer=xmlCompositeCollectionMapping.getContainerAccessor().getAttributeValueFromObject(objectValue);
      if (backpointerContainer == null) {
        backpointerContainer=xmlCompositeCollectionMapping.getBidirectionalPolicy().getBidirectionalTargetContainerPolicy().containerInstance();
        xmlCompositeCollectionMapping.getContainerAccessor().setAttributeValueInObject(objectValue,backpointerContainer);
      }
      xmlCompositeCollectionMapping.getBidirectionalPolicy().getBidirectionalTargetContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
    }
  }
  unmarshalRecord.setChildRecord(null);
}