Program: 64820
Project: 64820
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() > 1)) {
      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.getNodes().size() > 1) {
        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);
  XMLInverseReferenceMapping inverseReferenceMapping=xmlCompositeCollectionMapping.getInverseReferenceMapping();
  if (null != inverseReferenceMapping) {
    if (inverseReferenceMapping.getContainerPolicy() == null) {
      inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(objectValue,unmarshalRecord.getCurrentObject());
    }
 else {
      Object backpointerContainer=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(objectValue);
      if (backpointerContainer == null) {
        backpointerContainer=inverseReferenceMapping.getContainerPolicy().containerInstance();
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(objectValue,backpointerContainer);
      }
      inverseReferenceMapping.getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
    }
  }
  unmarshalRecord.setChildRecord(null);
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Object collection){
  if (unmarshalRecord.isNil() && xmlCompositeCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil()) {
    unmarshalRecord.resetStringBuffer();
    return;
  }
  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() > 1)) {
      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.getNodes().size() > 1) {
        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);
  XMLInverseReferenceMapping inverseReferenceMapping=xmlCompositeCollectionMapping.getInverseReferenceMapping();
  if (null != inverseReferenceMapping) {
    if (inverseReferenceMapping.getContainerPolicy() == null) {
      inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(objectValue,unmarshalRecord.getCurrentObject());
    }
 else {
      Object backpointerContainer=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(objectValue);
      if (backpointerContainer == null) {
        backpointerContainer=inverseReferenceMapping.getContainerPolicy().containerInstance();
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(objectValue,backpointerContainer);
      }
      inverseReferenceMapping.getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
    }
  }
  unmarshalRecord.setChildRecord(null);
}