Program: 64100
Project: 64100
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);
    marshalRecord.addXsiTypeAndClassIndicatorIfRequired(descriptor,(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor(),(Field)xmlCompositeCollectionMapping.getField(),false);
    CoreAttributeGroup group=marshalRecord.getCurrentAttributeGroup();
    CoreAttributeGroup nestedGroup=XMLRecord.DEFAULT_ATTRIBUTE_GROUP;
    CoreAttributeItem item=group.getItem(getMapping().getAttributeName());
    if (item != null && item.getGroup() != null) {
      nestedGroup=item.getGroup();
    }
    marshalRecord.pushAttributeGroup(nestedGroup);
    objectBuilder.buildRow(marshalRecord,value,session,marshaller,xPathFragment);
    marshalRecord.afterContainmentMarshal(object,value);
    marshalRecord.popAttributeGroup();
    marshalRecord.endElement(xPathFragment,namespaceResolver);
    marshalRecord.removeExtraNamespacesFromNamespaceResolver(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);
    marshalRecord.addXsiTypeAndClassIndicatorIfRequired(descriptor,(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor(),(Field)xmlCompositeCollectionMapping.getField(),false);
    CoreAttributeGroup group=marshalRecord.getCurrentAttributeGroup();
    CoreAttributeGroup nestedGroup=XMLRecord.DEFAULT_ATTRIBUTE_GROUP;
    CoreAttributeItem item=group.getItem(getMapping().getAttributeName());
    if (item != null) {
      if (item.getGroups() != null) {
        nestedGroup=item.getGroup(descriptor.getJavaClass());
      }
      if (nestedGroup == null) {
        nestedGroup=item.getGroup() == null ? XMLRecord.DEFAULT_ATTRIBUTE_GROUP : item.getGroup();
      }
    }
    marshalRecord.pushAttributeGroup(nestedGroup);
    objectBuilder.buildRow(marshalRecord,value,session,marshaller,xPathFragment);
    marshalRecord.afterContainmentMarshal(object,value);
    marshalRecord.popAttributeGroup();
    marshalRecord.endElement(xPathFragment,namespaceResolver);
    marshalRecord.removeExtraNamespacesFromNamespaceResolver(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;
}