Program: 68429
Project: 68429
Buggy source:
public void marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  if (xPathFragment.hasLeafElementType()) {
    marshalRecord.setLeafElementType(xPathFragment.getLeafElementType());
  }
  XMLMarshaller marshaller=marshalRecord.getMarshaller();
  if (xmlCompositeCollectionMapping.hasConverter()) {
    Converter converter=xmlCompositeCollectionMapping.getConverter();
    if (converter instanceof XMLConverter) {
      value=((XMLConverter)converter).convertObjectValueToDataValue(value,session,marshaller);
    }
 else {
      value=converter.convertObjectValueToDataValue(value,session);
    }
  }
  XMLDescriptor descriptor=(XMLDescriptor)session.getDescriptor(value);
  TreeObjectBuilder objectBuilder=(TreeObjectBuilder)descriptor.getObjectBuilder();
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().beforeMarshal(value);
  }
  getXPathNode().startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,objectBuilder,value);
  if ((xmlCompositeCollectionMapping.getReferenceDescriptor() == null) && (descriptor.getSchemaReference() != null)) {
    addTypeAttributeIfNeeded(descriptor,xmlCompositeCollectionMapping,marshalRecord);
  }
  List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session);
  writeExtraNamespaces(extraNamespaces,marshalRecord,session);
  objectBuilder.buildRow(marshalRecord,value,session,marshaller);
  marshalRecord.endElement(xPathFragment,namespaceResolver);
  objectBuilder.removeExtraNamespacesFromNamespaceResolver(marshalRecord,extraNamespaces,session);
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().afterMarshal(value);
  }
}

Fixed version (ground truth):
public void marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  if (xPathFragment.hasLeafElementType()) {
    marshalRecord.setLeafElementType(xPathFragment.getLeafElementType());
  }
  XMLMarshaller marshaller=marshalRecord.getMarshaller();
  if (xmlCompositeCollectionMapping.hasConverter()) {
    Converter converter=xmlCompositeCollectionMapping.getConverter();
    if (converter instanceof XMLConverter) {
      value=((XMLConverter)converter).convertObjectValueToDataValue(value,session,marshaller);
    }
 else {
      value=converter.convertObjectValueToDataValue(value,session);
    }
  }
  if (null == value) {
    xmlCompositeCollectionMapping.getNullPolicy().compositeObjectMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
    return;
  }
  XMLDescriptor descriptor=(XMLDescriptor)session.getDescriptor(value);
  TreeObjectBuilder objectBuilder=(TreeObjectBuilder)descriptor.getObjectBuilder();
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().beforeMarshal(value);
  }
  getXPathNode().startElement(marshalRecord,xPathFragment,object,session,namespaceResolver,objectBuilder,value);
  if ((xmlCompositeCollectionMapping.getReferenceDescriptor() == null) && (descriptor.getSchemaReference() != null)) {
    addTypeAttributeIfNeeded(descriptor,xmlCompositeCollectionMapping,marshalRecord);
  }
  List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session);
  writeExtraNamespaces(extraNamespaces,marshalRecord,session);
  objectBuilder.buildRow(marshalRecord,value,session,marshaller);
  marshalRecord.endElement(xPathFragment,namespaceResolver);
  objectBuilder.removeExtraNamespacesFromNamespaceResolver(marshalRecord,extraNamespaces,session);
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().afterMarshal(value);
  }
}