Program: 64409
Project: 64409
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Marshaller marshaller=marshalRecord.getMarshaller();
  value=xmlCompositeCollectionMapping.convertObjectValueToDataValue(value,session,marshaller);
  if (null == value) {
    return xmlCompositeCollectionMapping.getNullPolicy().compositeObjectMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
  Descriptor descriptor=(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor();
  if (descriptor == null) {
    descriptor=(Descriptor)session.getDescriptor(value.getClass());
  }
 else   if (descriptor.hasInheritance()) {
    Class objectValueClass=value.getClass();
    if (!(objectValueClass == descriptor.getJavaClass())) {
      descriptor=(Descriptor)session.getDescriptor(objectValueClass);
    }
  }
  UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeCollectionMapping.getKeepAsElementPolicy();
  if (null != keepAsElementPolicy && (keepAsElementPolicy.isKeepUnknownAsElement() || keepAsElementPolicy.isKeepAllAsElement()) && value instanceof org.w3c.dom.Node) {
    marshalRecord.node((org.w3c.dom.Node)value,marshalRecord.getNamespaceResolver());
    return true;
  }
  if (descriptor != null) {
    marshalRecord.beforeContainmentMarshal(value);
    ObjectBuilder objectBuilder=(ObjectBuilder)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,(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor(),(Field)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 (Constants.UNKNOWN_OR_TRANSIENT_CLASS.equals(xmlCompositeCollectionMapping.getReferenceClassName())) {
      throw XMLMarshalException.descriptorNotFoundInProject(value.getClass().getName());
    }
    xPathNode.startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,null,value);
    QName schemaType=((Field)xmlCompositeCollectionMapping.getField()).getSchemaTypeForValue(value,session);
    updateNamespaces(schemaType,marshalRecord,((Field)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,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Marshaller marshaller=marshalRecord.getMarshaller();
  value=xmlCompositeCollectionMapping.convertObjectValueToDataValue(value,session,marshaller);
  if (null == value) {
    return xmlCompositeCollectionMapping.getNullPolicy().compositeObjectMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
  Descriptor descriptor=(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor();
  if (descriptor == null) {
    descriptor=(Descriptor)session.getDescriptor(value.getClass());
  }
 else   if (descriptor.hasInheritance()) {
    Class objectValueClass=value.getClass();
    if (!(objectValueClass == descriptor.getJavaClass())) {
      descriptor=(Descriptor)session.getDescriptor(objectValueClass);
    }
  }
  UnmarshalKeepAsElementPolicy keepAsElementPolicy=xmlCompositeCollectionMapping.getKeepAsElementPolicy();
  if (null != keepAsElementPolicy && (keepAsElementPolicy.isKeepUnknownAsElement() || keepAsElementPolicy.isKeepAllAsElement()) && value instanceof org.w3c.dom.Node) {
    marshalRecord.node((org.w3c.dom.Node)value,marshalRecord.getNamespaceResolver());
    return true;
  }
  if (descriptor != null) {
    marshalRecord.beforeContainmentMarshal(value);
    ObjectBuilder objectBuilder=(ObjectBuilder)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,(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor(),(Field)xmlCompositeCollectionMapping.getField(),false);
    objectBuilder.buildRow(marshalRecord,value,session,marshaller,xPathFragment);
    marshalRecord.afterContainmentMarshal(object,value);
    marshalRecord.endElement(xPathFragment,namespaceResolver);
    objectBuilder.removeExtraNamespacesFromNamespaceResolver(marshalRecord,extraNamespaces,session);
  }
 else {
    if (Constants.UNKNOWN_OR_TRANSIENT_CLASS.equals(xmlCompositeCollectionMapping.getReferenceClassName())) {
      throw XMLMarshalException.descriptorNotFoundInProject(value.getClass().getName());
    }
    xPathNode.startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,null,value);
    QName schemaType=((Field)xmlCompositeCollectionMapping.getField()).getSchemaTypeForValue(value,session);
    updateNamespaces(schemaType,marshalRecord,((Field)xmlCompositeCollectionMapping.getField()));
    marshalRecord.characters(schemaType,value,null,false);
    marshalRecord.endElement(xPathFragment,namespaceResolver);
  }
  return true;
}