Program: 68605
Project: 68605
Buggy source:
public AbstractRecord buildRow(AbstractRecord databaseRow,Object object,AbstractSession session,boolean wasXMLRoot){
  XMLRecord row=(XMLRecord)databaseRow;
  XMLMarshaller marshaller=row.getMarshaller();
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().beforeMarshal(object);
  }
  writeOutMappings(row,object,session);
  if (getDescriptor().hasInheritance()) {
    boolean shouldAddClassIndicatorFieldToRow=true;
    if (isXmlDescriptor() && !wasXMLRoot) {
      XMLDescriptor xmlDescriptor=(XMLDescriptor)getDescriptor();
      if ((xmlDescriptor.getDefaultRootElementType() != null) && (xmlDescriptor.getSchemaReference() != null)) {
        XMLSchemaReference xmlRef=xmlDescriptor.getSchemaReference();
        if ((xmlRef.getType() == 1) && xmlRef.isGlobalDefinition()) {
          QName ctx=xmlRef.getSchemaContextAsQName(xmlDescriptor.getNamespaceResolver());
          if (ctx != null) {
            shouldAddClassIndicatorFieldToRow=false;
            if (!ctx.equals(xmlDescriptor.getDefaultRootElementType())) {
              row.add(xmlDescriptor.getInheritancePolicy().getClassIndicatorField(),xmlRef.getSchemaContext().substring(1));
            }
          }
        }
      }
    }
    if (shouldAddClassIndicatorFieldToRow) {
      getDescriptor().getInheritancePolicy().addClassIndicatorFieldToRow(row);
    }
  }
  if (!getDescriptor().isAggregateDescriptor()) {
    addPrimaryKeyForNonDefaultTable(row);
  }
  addNamespaceDeclarations((row).getDocument());
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().afterMarshal(object);
  }
  return row;
}

Fixed version (ground truth):
public AbstractRecord buildRow(AbstractRecord databaseRow,Object object,AbstractSession session,boolean wasXMLRoot){
  XMLRecord row=(XMLRecord)databaseRow;
  row.setSession(session);
  XMLMarshaller marshaller=row.getMarshaller();
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().beforeMarshal(object);
  }
  writeOutMappings(row,object,session);
  if (getDescriptor().hasInheritance()) {
    boolean shouldAddClassIndicatorFieldToRow=true;
    if (isXmlDescriptor() && !wasXMLRoot) {
      XMLDescriptor xmlDescriptor=(XMLDescriptor)getDescriptor();
      if ((xmlDescriptor.getDefaultRootElementType() != null) && (xmlDescriptor.getSchemaReference() != null)) {
        XMLSchemaReference xmlRef=xmlDescriptor.getSchemaReference();
        if ((xmlRef.getType() == 1) && xmlRef.isGlobalDefinition()) {
          QName ctx=xmlRef.getSchemaContextAsQName(xmlDescriptor.getNamespaceResolver());
          if (ctx != null) {
            shouldAddClassIndicatorFieldToRow=false;
            if (!ctx.equals(xmlDescriptor.getDefaultRootElementType())) {
              row.add(xmlDescriptor.getInheritancePolicy().getClassIndicatorField(),xmlRef.getSchemaContext().substring(1));
            }
          }
        }
      }
    }
    if (shouldAddClassIndicatorFieldToRow) {
      getDescriptor().getInheritancePolicy().addClassIndicatorFieldToRow(row);
    }
  }
  if (!getDescriptor().isAggregateDescriptor()) {
    addPrimaryKeyForNonDefaultTable(row);
  }
  addNamespaceDeclarations((row).getDocument());
  if ((marshaller != null) && (marshaller.getMarshalListener() != null)) {
    marshaller.getMarshalListener().afterMarshal(object);
  }
  return row;
}