Program: 64391
Project: 64391
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 XMLRoot)) {
    xmlRootFragment=new XPathFragment();
    xmlRootFragment.setNamespaceAware(marshalRecord.isNamespaceAware());
    wasXMLRoot=true;
    objectValue=((XMLRoot)objectValue).getObject();
  }
  if (objectValue instanceof String) {
    marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
  }
 else {
    CoreSession childSession=null;
    try {
      childSession=marshaller.getXMLContext().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) {
      Namespace generatedNamespace=setupFragment(((XMLRoot)originalValue),xmlRootFragment,marshalRecord);
      if (generatedNamespace != null) {
        extraNamespaces.add(generatedNamespace);
      }
    }
    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);
      objectBuilder.addXsiTypeAndClassIndicatorIfRequired(marshalRecord,descriptor,descriptor,(Field)xmlAnyObjectMapping.getField(),originalValue,objectValue,wasXMLRoot,false);
      objectBuilder.buildRow(marshalRecord,objectValue,(org.eclipse.persistence.internal.sessions.AbstractSession)childSession,marshaller,null,WriteType.UNDEFINED);
      marshalRecord.afterContainmentMarshal(object,objectValue);
      marshalRecord.endElement(rootFragment,namespaceResolver);
      objectBuilder.removeExtraNamespacesFromNamespaceResolver(marshalRecord,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 instanceof String) {
    marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
  }
 else {
    CoreSession childSession=null;
    try {
      childSession=marshaller.getXMLContext().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) {
      Namespace generatedNamespace=setupFragment(((Root)originalValue),xmlRootFragment,marshalRecord);
      if (generatedNamespace != null) {
        extraNamespaces.add(generatedNamespace);
      }
    }
    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);
      objectBuilder.addXsiTypeAndClassIndicatorIfRequired(marshalRecord,descriptor,descriptor,(Field)xmlAnyObjectMapping.getField(),originalValue,objectValue,wasXMLRoot,false);
      objectBuilder.buildRow(marshalRecord,objectValue,(org.eclipse.persistence.internal.sessions.AbstractSession)childSession,marshaller,null,WriteType.UNDEFINED);
      marshalRecord.afterContainmentMarshal(object,objectValue);
      marshalRecord.endElement(rootFragment,namespaceResolver);
      objectBuilder.removeExtraNamespacesFromNamespaceResolver(marshalRecord,extraNamespaces,session);
    }
  }
  return true;
}