Program: 65672
Project: 65672
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  XPathFragment rootFragment=null;
  XMLMarshaller marshaller=marshalRecord.getMarshaller();
  if (xmlAnyObjectMapping.getConverter() != null) {
    objectValue=xmlAnyObjectMapping.getConverter().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();
    wasXMLRoot=true;
    objectValue=((XMLRoot)objectValue).getObject();
  }
  if (objectValue instanceof String) {
    marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
  }
 else {
    Session childSession=null;
    try {
      childSession=marshaller.getXMLContext().getSession(objectValue);
    }
 catch (    XMLMarshalException e) {
      marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
      return true;
    }
    XMLDescriptor descriptor=(XMLDescriptor)childSession.getDescriptor(objectValue);
    TreeObjectBuilder objectBuilder=(TreeObjectBuilder)descriptor.getObjectBuilder();
    List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session);
    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,(XMLField)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,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  XPathFragment rootFragment=null;
  XMLMarshaller marshaller=marshalRecord.getMarshaller();
  if (xmlAnyObjectMapping.getConverter() != null) {
    objectValue=xmlAnyObjectMapping.getConverter().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 {
    Session childSession=null;
    try {
      childSession=marshaller.getXMLContext().getSession(objectValue);
    }
 catch (    XMLMarshalException e) {
      marshalSimpleValue(xmlRootFragment,marshalRecord,originalValue,object,objectValue,session,namespaceResolver);
      return true;
    }
    XMLDescriptor descriptor=(XMLDescriptor)childSession.getDescriptor(objectValue);
    TreeObjectBuilder objectBuilder=(TreeObjectBuilder)descriptor.getObjectBuilder();
    List extraNamespaces=objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor,marshalRecord,session);
    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,(XMLField)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;
}