Program: 63860
Project: 63860
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  XPathFragment rootFragment=null;
  Marshaller marshaller=marshalRecord.getMarshaller();
  objectValue=xmlAnyObjectMapping.convertObjectValueToDataValue(objectValue,session,marshalRecord.getMarshaller());
  if (null == objectValue) {
    return false;
  }
  XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
  marshalRecord.closeStartGroupingElements(groupingFragment);
  boolean wasXMLRoot=false;
  XPathFragment xmlRootFragment=null;
  Object originalValue=objectValue;
  if (xmlAnyObjectMapping.usesXMLRoot() && (objectValue instanceof Root)) {
    xmlRootFragment=new XPathFragment();
    xmlRootFragment.setNamespaceAware(marshalRecord.isNamespaceAware());
    wasXMLRoot=true;
    objectValue=((Root)objectValue).getObject();
    if (objectValue == null) {
      setupFragment(((Root)originalValue),xmlRootFragment,marshalRecord);
      marshalRecord.nilComplex(xmlRootFragment,namespaceResolver);
      return true;
    }
  }
  if (objectValue instanceof String) {
    marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
  }
 else {
    CoreSession childSession=null;
    try {
      childSession=marshaller.getContext().getSession(objectValue);
    }
 catch (    XMLMarshalException e) {
      marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
      return true;
    }
    Descriptor descriptor=(Descriptor)childSession.getDescriptor(objectValue);
    ObjectBuilder objectBuilder=(ObjectBuilder)descriptor.getObjectBuilder();
    List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session,true,true);
    if (wasXMLRoot) {
      setupFragment(((Root)originalValue),xmlRootFragment,marshalRecord);
    }
    String defaultRootElementString=descriptor.getDefaultRootElement();
    if (!wasXMLRoot && (defaultRootElementString == null)) {
      AbstractSessionLog.getLog().log(SessionLog.WARNING,"String_Node_Str",new Object[]{Helper.getShortClassName(this.getClass()),descriptor});
    }
 else {
      marshalRecord.beforeContainmentMarshal(objectValue);
      if (xmlRootFragment != null) {
        rootFragment=xmlRootFragment;
      }
 else {
        rootFragment=new XPathFragment(defaultRootElementString);
        if (rootFragment.getNamespaceURI() == null) {
          if (rootFragment.getPrefix() != null) {
            String uri=descriptor.getNonNullNamespaceResolver().resolveNamespacePrefix(rootFragment.getPrefix());
            rootFragment.setNamespaceURI(uri);
          }
 else {
            rootFragment.setNamespaceURI(descriptor.getNonNullNamespaceResolver().getDefaultNamespaceURI());
          }
        }
      }
      if (!wasXMLRoot) {
        marshalRecord.setLeafElementType(descriptor.getDefaultRootElementType());
      }
      getXPathNode().startElement(marshalRecord,rootFragment,object,session,descriptor.getNonNullNamespaceResolver(),objectBuilder,objectValue);
      writeExtraNamespaces(extraNamespaces,marshalRecord,session);
      marshalRecord.addXsiTypeAndClassIndicatorIfRequired(descriptor,descriptor,(Field)xmlAnyObjectMapping.getField(),originalValue,objectValue,wasXMLRoot,false);
      objectBuilder.buildRow(marshalRecord,objectValue,(org.eclipse.persistence.internal.sessions.AbstractSession)childSession,marshaller,null);
      marshalRecord.afterContainmentMarshal(object,objectValue);
      marshalRecord.endElement(rootFragment,namespaceResolver);
      marshalRecord.removeExtraNamespacesFromNamespaceResolver(extraNamespaces,session);
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  XPathFragment rootFragment=null;
  Marshaller marshaller=marshalRecord.getMarshaller();
  objectValue=xmlAnyObjectMapping.convertObjectValueToDataValue(objectValue,session,marshalRecord.getMarshaller());
  if (null == objectValue) {
    return false;
  }
  XPathFragment groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
  marshalRecord.closeStartGroupingElements(groupingFragment);
  boolean wasXMLRoot=false;
  XPathFragment xmlRootFragment=null;
  Object originalValue=objectValue;
  if (xmlAnyObjectMapping.usesXMLRoot() && (objectValue instanceof Root)) {
    xmlRootFragment=new XPathFragment();
    xmlRootFragment.setNamespaceAware(marshalRecord.isNamespaceAware());
    wasXMLRoot=true;
    objectValue=((Root)objectValue).getObject();
    if (objectValue == null) {
      setupFragment(((Root)originalValue),xmlRootFragment,marshalRecord);
      marshalRecord.nilComplex(xmlRootFragment,namespaceResolver);
      return true;
    }
  }
  if (objectValue instanceof String) {
    marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
  }
 else {
    CoreSession childSession=null;
    try {
      childSession=marshaller.getContext().getSession(objectValue);
    }
 catch (    XMLMarshalException e) {
      marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
      return true;
    }
    Descriptor descriptor=(Descriptor)childSession.getDescriptor(objectValue);
    ObjectBuilder objectBuilder=(ObjectBuilder)descriptor.getObjectBuilder();
    List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session,true,true);
    if (wasXMLRoot) {
      setupFragment(((Root)originalValue),xmlRootFragment,marshalRecord);
    }
    String defaultRootElementString=descriptor.getDefaultRootElement();
    if (!wasXMLRoot && (defaultRootElementString == null)) {
      throw XMLMarshalException.defaultRootElementNotSpecified((XMLDescriptor)descriptor);
    }
 else {
      marshalRecord.beforeContainmentMarshal(objectValue);
      if (xmlRootFragment != null) {
        rootFragment=xmlRootFragment;
      }
 else {
        rootFragment=new XPathFragment(defaultRootElementString);
        if (rootFragment.getNamespaceURI() == null) {
          if (rootFragment.getPrefix() != null) {
            String uri=descriptor.getNonNullNamespaceResolver().resolveNamespacePrefix(rootFragment.getPrefix());
            rootFragment.setNamespaceURI(uri);
          }
 else {
            rootFragment.setNamespaceURI(descriptor.getNonNullNamespaceResolver().getDefaultNamespaceURI());
          }
        }
      }
      if (!wasXMLRoot) {
        marshalRecord.setLeafElementType(descriptor.getDefaultRootElementType());
      }
      getXPathNode().startElement(marshalRecord,rootFragment,object,session,descriptor.getNonNullNamespaceResolver(),objectBuilder,objectValue);
      writeExtraNamespaces(extraNamespaces,marshalRecord,session);
      marshalRecord.addXsiTypeAndClassIndicatorIfRequired(descriptor,descriptor,(Field)xmlAnyObjectMapping.getField(),originalValue,objectValue,wasXMLRoot,false);
      objectBuilder.buildRow(marshalRecord,objectValue,(org.eclipse.persistence.internal.sessions.AbstractSession)childSession,marshaller,null);
      marshalRecord.afterContainmentMarshal(object,objectValue);
      marshalRecord.endElement(rootFragment,namespaceResolver);
      marshalRecord.removeExtraNamespacesFromNamespaceResolver(extraNamespaces,session);
    }
  }
  return true;
}