Program: 64749
Project: 64749
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  XMLMarshaller marshaller=marshalRecord.getMarshaller();
  Converter converter=xmlCompositeCollectionMapping.getConverter();
  if (null != converter) {
    if (converter instanceof XMLConverter) {
      value=((XMLConverter)converter).convertObjectValueToDataValue(value,session,marshaller);
    }
 else {
      value=converter.convertObjectValueToDataValue(value,session);
    }
  }
  if (null == value) {
    return xmlCompositeCollectionMapping.getNullPolicy().compositeObjectMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
  XMLDescriptor descriptor=(XMLDescriptor)xmlCompositeCollectionMapping.getReferenceDescriptor();
  if (descriptor == null) {
    descriptor=(XMLDescriptor)session.getDescriptor(value.getClass());
  }
 else   if (descriptor.hasInheritance()) {
    Class objectValueClass=value.getClass();
    if (!(objectValueClass == descriptor.getJavaClass())) {
      descriptor=(XMLDescriptor)session.getDescriptor(objectValueClass);
    }
  }
  UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeCollectionMapping.getKeepAsElementPolicy();
  if (((keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) && value instanceof org.w3c.dom.Node) {
    marshalRecord.node((org.w3c.dom.Node)value,marshalRecord.getNamespaceResolver());
    return true;
  }
  if (descriptor != null) {
    marshalRecord.beforeContainmentMarshal(value);
    TreeObjectBuilder objectBuilder=(TreeObjectBuilder)descriptor.getObjectBuilder();
    xPathNode.startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,objectBuilder,value);
    List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session,true,false);
    writeExtraNamespaces(extraNamespaces,marshalRecord,session);
    objectBuilder.addXsiTypeAndClassIndicatorIfRequired(marshalRecord,descriptor,(XMLDescriptor)xmlCompositeCollectionMapping.getReferenceDescriptor(),(XMLField)xmlCompositeCollectionMapping.getField(),false);
    objectBuilder.buildRow(marshalRecord,value,session,marshaller,xPathFragment,WriteType.UNDEFINED);
    marshalRecord.afterContainmentMarshal(object,value);
    marshalRecord.endElement(xPathFragment,namespaceResolver);
    objectBuilder.removeExtraNamespacesFromNamespaceResolver(marshalRecord,extraNamespaces,session);
  }
 else {
    xPathNode.startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,null,value);
    QName schemaType=((XMLField)xmlCompositeCollectionMapping.getField()).getSchemaTypeForValue(value,session);
    updateNamespaces(schemaType,marshalRecord,((XMLField)xmlCompositeCollectionMapping.getField()));
    marshalRecord.characters(schemaType,value,null,false);
    marshalRecord.endElement(xPathFragment,namespaceResolver);
  }
  return true;
}

Fixed version (ground truth):
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  XMLMarshaller marshaller=marshalRecord.getMarshaller();
  Converter converter=xmlCompositeCollectionMapping.getConverter();
  if (null != converter) {
    if (converter instanceof XMLConverter) {
      value=((XMLConverter)converter).convertObjectValueToDataValue(value,session,marshaller);
    }
 else {
      value=converter.convertObjectValueToDataValue(value,session);
    }
  }
  if (null == value) {
    return xmlCompositeCollectionMapping.getNullPolicy().compositeObjectMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
  XMLDescriptor descriptor=(XMLDescriptor)xmlCompositeCollectionMapping.getReferenceDescriptor();
  if (descriptor == null) {
    descriptor=(XMLDescriptor)session.getDescriptor(value.getClass());
  }
 else   if (descriptor.hasInheritance()) {
    Class objectValueClass=value.getClass();
    if (!(objectValueClass == descriptor.getJavaClass())) {
      descriptor=(XMLDescriptor)session.getDescriptor(objectValueClass);
    }
  }
  UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeCollectionMapping.getKeepAsElementPolicy();
  if (((keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)) && value instanceof org.w3c.dom.Node) {
    marshalRecord.node((org.w3c.dom.Node)value,marshalRecord.getNamespaceResolver());
    return true;
  }
  if (descriptor != null) {
    marshalRecord.beforeContainmentMarshal(value);
    TreeObjectBuilder objectBuilder=(TreeObjectBuilder)descriptor.getObjectBuilder();
    xPathNode.startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,objectBuilder,value);
    List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session,true,false);
    writeExtraNamespaces(extraNamespaces,marshalRecord,session);
    objectBuilder.addXsiTypeAndClassIndicatorIfRequired(marshalRecord,descriptor,(XMLDescriptor)xmlCompositeCollectionMapping.getReferenceDescriptor(),(XMLField)xmlCompositeCollectionMapping.getField(),false);
    objectBuilder.buildRow(marshalRecord,value,session,marshaller,xPathFragment,WriteType.UNDEFINED);
    marshalRecord.afterContainmentMarshal(object,value);
    marshalRecord.endElement(xPathFragment,namespaceResolver);
    objectBuilder.removeExtraNamespacesFromNamespaceResolver(marshalRecord,extraNamespaces,session);
  }
 else {
    if (XMLConstants.UNKNOWN_OR_TRANSIENT_CLASS.equals(xmlCompositeCollectionMapping.getReferenceClassName())) {
      throw XMLMarshalException.descriptorNotFoundInProject(value.getClass().getName());
    }
    xPathNode.startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,null,value);
    QName schemaType=((XMLField)xmlCompositeCollectionMapping.getField()).getSchemaTypeForValue(value,session);
    updateNamespaces(schemaType,marshalRecord,((XMLField)xmlCompositeCollectionMapping.getField()));
    marshalRecord.characters(schemaType,value,null,false);
    marshalRecord.endElement(xPathFragment,namespaceResolver);
  }
  return true;
}