Program: 65538
Project: 65538
Buggy source:
public boolean marshalAttributes(MarshalRecord marshalRecord,Object object,AbstractSession session){
  lazyInitialize();
  boolean hasValue=false;
  NamespaceResolver namespaceResolver=((XMLDescriptor)descriptor).getNamespaceResolver();
  List<XPathNode> attributeChildren=rootXPathNode.getAttributeChildren();
  if (null != attributeChildren) {
    ObjectMarshalContext objectMarshalContext=ObjectMarshalContext.getInstance();
    for (int x=0, attributeChildrenSize=attributeChildren.size(); x < attributeChildrenSize; x++) {
      hasValue=attributeChildren.get(x).marshal(marshalRecord,object,session,namespaceResolver,null,objectMarshalContext,null) || hasValue;
    }
  }
  if (rootXPathNode.getAnyAttributeNode() != null) {
    hasValue=rootXPathNode.getAnyAttributeNode().marshal(marshalRecord,object,session,namespaceResolver,null,ObjectMarshalContext.getInstance(),null) || hasValue;
  }
  List<XPathNode> selfChildren=rootXPathNode.getSelfChildren();
  if (null != selfChildren) {
    for (    XPathNode selfXPathNode : selfChildren) {
      NodeValue marshalNodeValue=selfXPathNode.getMarshalNodeValue();
      if (marshalNodeValue instanceof MappingNodeValue) {
        DatabaseMapping selfMapping=((MappingNodeValue)marshalNodeValue).getMapping();
        Object value=selfMapping.getAttributeValueFromObject(object);
        XMLDescriptor referenceDescriptor=(XMLDescriptor)selfMapping.getReferenceDescriptor();
        XMLDescriptor valueDescriptor;
        if (value != null && (referenceDescriptor == null || referenceDescriptor.hasInheritance())) {
          valueDescriptor=(XMLDescriptor)session.getDescriptor(value.getClass());
        }
 else {
          valueDescriptor=referenceDescriptor;
        }
        if (null != valueDescriptor) {
          this.addXsiTypeAndClassIndicatorIfRequired(marshalRecord,valueDescriptor,referenceDescriptor,(XMLField)selfMapping.getField(),false);
        }
      }
      selfXPathNode.marshalSelfAttributes(marshalRecord,object,session,namespaceResolver,marshalRecord.getMarshaller());
    }
  }
  return hasValue;
}

Fixed version (ground truth):
public boolean marshalAttributes(MarshalRecord marshalRecord,Object object,AbstractSession session){
  lazyInitialize();
  boolean hasValue=false;
  NamespaceResolver namespaceResolver=((XMLDescriptor)descriptor).getNamespaceResolver();
  List<XPathNode> attributeChildren=rootXPathNode.getAttributeChildren();
  if (null != attributeChildren) {
    ObjectMarshalContext objectMarshalContext=ObjectMarshalContext.getInstance();
    for (int x=0, attributeChildrenSize=attributeChildren.size(); x < attributeChildrenSize; x++) {
      hasValue=attributeChildren.get(x).marshal(marshalRecord,object,session,namespaceResolver,null,objectMarshalContext,null) || hasValue;
    }
  }
  if (rootXPathNode.getAnyAttributeNode() != null) {
    hasValue=rootXPathNode.getAnyAttributeNode().marshal(marshalRecord,object,session,namespaceResolver,null,ObjectMarshalContext.getInstance(),null) || hasValue;
  }
  List<XPathNode> selfChildren=rootXPathNode.getSelfChildren();
  if (null != selfChildren) {
    for (    XPathNode selfXPathNode : selfChildren) {
      NodeValue marshalNodeValue=selfXPathNode.getMarshalNodeValue();
      if (marshalNodeValue instanceof MappingNodeValue) {
        DatabaseMapping selfMapping=((MappingNodeValue)marshalNodeValue).getMapping();
        Object value=selfMapping.getAttributeValueFromObject(object);
        XMLDescriptor referenceDescriptor=(XMLDescriptor)selfMapping.getReferenceDescriptor();
        XMLDescriptor valueDescriptor;
        if (value != null && (referenceDescriptor == null || referenceDescriptor.hasInheritance())) {
          valueDescriptor=(XMLDescriptor)session.getDescriptor(value.getClass());
        }
 else {
          valueDescriptor=referenceDescriptor;
        }
        if (null != valueDescriptor) {
          ((XMLObjectBuilder)valueDescriptor.getObjectBuilder()).addXsiTypeAndClassIndicatorIfRequired(marshalRecord,valueDescriptor,referenceDescriptor,(XMLField)selfMapping.getField(),false);
        }
      }
      selfXPathNode.marshalSelfAttributes(marshalRecord,object,session,namespaceResolver,marshalRecord.getMarshaller());
    }
  }
  return hasValue;
}