Program: 67398
Project: 67398
Buggy source:
public void marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  NodeValue associatedNodeValue=null;
  XMLField associatedField=null;
  Object fieldValue=value;
  if (value instanceof XMLRoot) {
    XMLRoot rootValue=(XMLRoot)value;
    String localName=rootValue.getLocalName();
    String namespaceUri=rootValue.getNamespaceURI();
    fieldValue=rootValue.getObject();
    associatedField=getFieldForName(localName,namespaceUri);
    if (associatedField == null) {
      associatedField=xmlChoiceCollectionMapping.getClassToFieldMappings().get(value.getClass());
    }
  }
 else {
    associatedField=xmlChoiceCollectionMapping.getClassToFieldMappings().get(value.getClass());
  }
  if (associatedField != null) {
    associatedNodeValue=this.fieldToNodeValues.get(associatedField);
  }
  if (associatedNodeValue != null) {
    XPathFragment frag=associatedField.getXPathFragment();
    while (frag != null) {
      if (associatedNodeValue.isOwningNode(frag)) {
        ContainerValue nestedNodeValue=(ContainerValue)((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementNodeValue();
        nestedNodeValue.marshalSingleValue(frag,marshalRecord,object,fieldValue,session,namespaceResolver,marshalContext);
        break;
      }
      frag=frag.getNextFragment();
      if (frag == null) {
        ContainerValue nestedNodeValue=(ContainerValue)((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementNodeValue();
        nestedNodeValue.marshalSingleValue(frag,marshalRecord,object,fieldValue,session,namespaceResolver,marshalContext);
      }
    }
  }
}

Fixed version (ground truth):
public void marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object value,AbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  NodeValue associatedNodeValue=null;
  XMLField associatedField=null;
  Object fieldValue=value;
  if (value instanceof XMLRoot) {
    XMLRoot rootValue=(XMLRoot)value;
    String localName=rootValue.getLocalName();
    String namespaceUri=rootValue.getNamespaceURI();
    fieldValue=rootValue.getObject();
    associatedField=getFieldForName(localName,namespaceUri);
    if (associatedField == null) {
      associatedField=xmlChoiceCollectionMapping.getClassToFieldMappings().get(fieldValue.getClass());
    }
  }
 else {
    associatedField=xmlChoiceCollectionMapping.getClassToFieldMappings().get(value.getClass());
  }
  if (associatedField != null) {
    associatedNodeValue=this.fieldToNodeValues.get(associatedField);
  }
  if (associatedNodeValue != null) {
    XPathFragment frag=associatedField.getXPathFragment();
    while (frag != null) {
      if (associatedNodeValue.isOwningNode(frag)) {
        ContainerValue nestedNodeValue=(ContainerValue)((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementNodeValue();
        nestedNodeValue.marshalSingleValue(frag,marshalRecord,object,fieldValue,session,namespaceResolver,marshalContext);
        break;
      }
      frag=frag.getNextFragment();
      if (frag == null) {
        ContainerValue nestedNodeValue=(ContainerValue)((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementNodeValue();
        nestedNodeValue.marshalSingleValue(frag,marshalRecord,object,fieldValue,session,namespaceResolver,marshalContext);
      }
    }
  }
}