Program: 63666
Project: 63666
Buggy source:
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Object fieldValue=xmlDirectMapping.getFieldValue(objectValue,session,marshalRecord);
  if (null == fieldValue) {
    return xmlDirectMapping.getNullPolicy().directMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
 else {
    QName schemaType=((Field)xmlDirectMapping.getField()).getSchemaTypeForValue(fieldValue,session);
    XPathFragment groupingFragment=null;
    boolean isQName=false;
    if (Constants.QNAME_QNAME.equals(schemaType)) {
      groupingFragment=openGroupingElementsForQName((QName)fieldValue,marshalRecord);
      isQName=true;
    }
    if (groupingFragment == null) {
      groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
    }
    if (xPathFragment.hasAttribute) {
      marshalRecord.attribute(xPathFragment,namespaceResolver,fieldValue,schemaType);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      marshalRecord.closeStartGroupingElements(groupingFragment);
      marshalRecord.characters(schemaType,fieldValue,null,xmlDirectMapping.isCDATA());
    }
    if (isQName) {
      XPathFragment fragment=getLastGroupingFragment();
      if (fragment != groupingFragment) {
        marshalRecord.endElement(groupingFragment,namespaceResolver);
        return false;
      }
    }
    return true;
  }
}

Fixed version (ground truth):
public boolean marshalSingleValue(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,Object objectValue,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  Object fieldValue=xmlDirectMapping.getFieldValue(objectValue,session,marshalRecord);
  if (null == fieldValue) {
    return xmlDirectMapping.getNullPolicy().directMarshal(xPathFragment,marshalRecord,object,session,namespaceResolver);
  }
 else {
    QName schemaType=((Field)xmlDirectMapping.getField()).getSchemaTypeForValue(fieldValue,session);
    XPathFragment groupingFragment=null;
    boolean isQName=false;
    if (Constants.QNAME_QNAME.equals(schemaType)) {
      groupingFragment=openGroupingElementsForQName((QName)fieldValue,marshalRecord);
      isQName=true;
    }
    if (groupingFragment == null) {
      groupingFragment=marshalRecord.openStartGroupingElements(namespaceResolver);
    }
    if (xPathFragment.hasAttribute) {
      marshalRecord.attribute(xPathFragment,namespaceResolver,fieldValue,schemaType);
      marshalRecord.closeStartGroupingElements(groupingFragment);
    }
 else {
      if (((Field)xmlDirectMapping.getField()).getXPathFragment().nameIsText) {
        XPathNode parentNode=xPathNode.getParent();
        if (parentNode.getAttributeChildren() != null) {
          marshalRecord.forceValueWrapper();
        }
      }
      marshalRecord.closeStartGroupingElements(groupingFragment);
      marshalRecord.characters(schemaType,fieldValue,null,xmlDirectMapping.isCDATA());
    }
    if (isQName) {
      XPathFragment fragment=getLastGroupingFragment();
      if (fragment != groupingFragment) {
        marshalRecord.endElement(groupingFragment,namespaceResolver);
        return false;
      }
    }
    return true;
  }
}