Program: 65278
Project: 65278
Buggy source:
public AbstractRecord buildRow(AbstractRecord record,Object object,org.eclipse.persistence.internal.sessions.AbstractSession session,XMLMarshaller marshaller,XPathFragment rootFragment,WriteType writeType){
  lazyInitialize();
  XPathNode textNode=rootXPathNode.getTextNode();
  List<XPathNode> nonAttributeChildren=rootXPathNode.getNonAttributeChildren();
  if (null == textNode && null == nonAttributeChildren) {
    return record;
  }
  XMLDescriptor xmlDescriptor=(XMLDescriptor)descriptor;
  NamespaceResolver namespaceResolver=xmlDescriptor.getNamespaceResolver();
  MarshalContext marshalContext=null;
  if (xmlDescriptor.isSequencedObject()) {
    SequencedObject sequencedObject=(SequencedObject)object;
    marshalContext=new SequencedMarshalContext(sequencedObject.getSettings());
  }
 else {
    marshalContext=ObjectMarshalContext.getInstance();
  }
  if (null == nonAttributeChildren) {
    textNode.marshal((MarshalRecord)record,object,session,namespaceResolver,marshaller,marshalContext,rootFragment);
  }
 else {
    for (int x=0, size=marshalContext.getNonAttributeChildrenSize(rootXPathNode); x < size; x++) {
      XPathNode xPathNode=(XPathNode)marshalContext.getNonAttributeChild(x,rootXPathNode);
      xPathNode.marshal((MarshalRecord)record,object,session,namespaceResolver,marshaller,marshalContext.getMarshalContext(x),rootFragment);
    }
  }
  return record;
}

Fixed version (ground truth):
public AbstractRecord buildRow(AbstractRecord record,Object object,org.eclipse.persistence.internal.sessions.AbstractSession session,XMLMarshaller marshaller,XPathFragment rootFragment,WriteType writeType){
  lazyInitialize();
  XPathNode textNode=rootXPathNode.getTextNode();
  List<XPathNode> nonAttributeChildren=rootXPathNode.getNonAttributeChildren();
  if (null == textNode && null == nonAttributeChildren) {
    return record;
  }
  XMLDescriptor xmlDescriptor=(XMLDescriptor)descriptor;
  XPathNode node=rootXPathNode;
  MarshalRecord marshalRecord=(MarshalRecord)record;
  QName schemaType=null;
  if (marshalRecord.getCycleDetectionStack().contains(object)) {
    if (cycleRecoverableClass == null) {
      initCycleRecoverableClasses();
    }
    if (cycleRecoverableClass.isAssignableFrom(object.getClass())) {
      try {
        Object jaxbMarshaller=marshaller.getProperty(XMLConstants.JAXB_MARSHALLER);
        Object contextProxy=CycleRecoverableContextProxy.getProxy(cycleRecoverableContextClass,jaxbMarshaller);
        Method onCycleDetectedMethod=object.getClass().getMethod(ON_CYCLE_DETECTED,new Class[]{cycleRecoverableContextClass});
        object=PrivilegedAccessHelper.invokeMethod(onCycleDetectedMethod,object,new Object[]{contextProxy});
      }
 catch (      Exception e) {
        throw XMLMarshalException.marshalException(e);
      }
      xmlDescriptor=(XMLDescriptor)session.getDescriptor(object.getClass());
      if (xmlDescriptor != null) {
        node=((TreeObjectBuilder)xmlDescriptor.getObjectBuilder()).getRootXPathNode();
      }
 else {
        node=null;
      }
      marshalRecord.getCycleDetectionStack().push(object);
      if (xmlDescriptor != descriptor) {
        if (xmlDescriptor == null) {
          schemaType=(QName)XMLConversionManager.getDefaultJavaTypes().get(object.getClass());
        }
 else {
          schemaType=xmlDescriptor.getSchemaReference().getSchemaContextAsQName();
        }
        writeXsiTypeAttribute(xmlDescriptor,(XMLRecord)record,schemaType,false);
      }
    }
 else {
      marshalRecord.getCycleDetectionStack().push(object);
      throw XMLMarshalException.objectCycleDetected(marshalRecord.getCycleDetectionStack().getCycleString());
    }
  }
 else {
    marshalRecord.getCycleDetectionStack().push(object);
  }
  NamespaceResolver namespaceResolver=null;
  if (xmlDescriptor != null) {
    namespaceResolver=xmlDescriptor.getNamespaceResolver();
  }
  MarshalContext marshalContext=null;
  if (xmlDescriptor != null && xmlDescriptor.isSequencedObject()) {
    SequencedObject sequencedObject=(SequencedObject)object;
    marshalContext=new SequencedMarshalContext(sequencedObject.getSettings());
  }
 else {
    marshalContext=ObjectMarshalContext.getInstance();
  }
  if (null == nonAttributeChildren) {
    textNode.marshal((MarshalRecord)record,object,session,namespaceResolver,marshaller,marshalContext,rootFragment);
  }
 else {
    if (node == null) {
      XPathNode n=new XPathNode();
      XMLCompositeObjectMapping m=new XMLCompositeObjectMapping();
      m.setXPath("String_Node_Str");
      XMLCompositeObjectMappingNodeValue nv=new XMLCompositeObjectMappingNodeValue(m);
      n.setMarshalNodeValue(nv);
      nv.marshalSingleValue(new XPathFragment("String_Node_Str"),marshalRecord,null,object,session,namespaceResolver,marshalContext);
    }
 else {
      for (int x=0, size=marshalContext.getNonAttributeChildrenSize(node); x < size; x++) {
        XPathNode xPathNode=(XPathNode)marshalContext.getNonAttributeChild(x,node);
        xPathNode.marshal((MarshalRecord)record,object,session,namespaceResolver,marshaller,marshalContext.getMarshalContext(x),rootFragment);
      }
    }
  }
  marshalRecord.getCycleDetectionStack().pop();
  return record;
}