Program: 67631
Project: 67631
Buggy source:
/** 
 * INTERNAL: Allow the inheritance properties of the descriptor to be initialized. The descriptor's parent must first be initialized.
 */
public void preInitialize(AbstractSession session) throws DescriptorException {
  if (isChildDescriptor()) {
    Vector<DatabaseTable> childTables=getDescriptor().getTables();
    Vector<DatabaseTable> parentTables=getParentDescriptor().getTables();
    Vector<DatabaseTable> uniqueTables=Helper.concatenateUniqueVectors(parentTables,childTables);
    getDescriptor().setTables(uniqueTables);
    if (childTables.isEmpty()) {
      getDescriptor().setInternalDefaultTable();
    }
 else {
      getDescriptor().setInternalDefaultTable(uniqueTables.get(uniqueTables.indexOf(childTables.get(0))));
    }
    setClassIndicatorMapping(getParentDescriptor().getInheritancePolicy().getClassIndicatorMapping());
    setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator());
    getDescriptor().setPrimaryKeyFields(getParentDescriptor().getPrimaryKeyFields());
    getDescriptor().setAdditionalTablePrimaryKeyFields(Helper.concatenateMaps(getParentDescriptor().getAdditionalTablePrimaryKeyFields(),getDescriptor().getAdditionalTablePrimaryKeyFields()));
    Expression localExpression=getDescriptor().getQueryManager().getMultipleTableJoinExpression();
    Expression parentExpression=getParentDescriptor().getQueryManager().getMultipleTableJoinExpression();
    if (localExpression != null) {
      getDescriptor().getQueryManager().setInternalMultipleTableJoinExpression(localExpression.and(parentExpression));
    }
 else     if (parentExpression != null) {
      getDescriptor().getQueryManager().setInternalMultipleTableJoinExpression(parentExpression);
    }
    Expression localAdditionalExpression=getDescriptor().getQueryManager().getAdditionalJoinExpression();
    Expression parentAdditionalExpression=getParentDescriptor().getQueryManager().getAdditionalJoinExpression();
    if (localAdditionalExpression != null) {
      getDescriptor().getQueryManager().setAdditionalJoinExpression(localAdditionalExpression.and(parentAdditionalExpression));
    }
 else     if (parentAdditionalExpression != null) {
      getDescriptor().getQueryManager().setAdditionalJoinExpression(parentAdditionalExpression);
    }
    setClassIndicatorField(getParentDescriptor().getInheritancePolicy().getClassIndicatorField());
    if (!getDescriptor().usesSequenceNumbers()) {
      getDescriptor().setSequenceNumberField(getParentDescriptor().getSequenceNumberField());
      getDescriptor().setSequenceNumberName(getParentDescriptor().getSequenceNumberName());
    }
  }
 else {
    getDescriptor().setInternalDefaultTable();
  }
  initializeClassExtractor(session);
  if (!isChildDescriptor()) {
    if ((getClassIndicatorField() == null) && (!hasClassExtractor())) {
      session.getIntegrityChecker().handleError(DescriptorException.classIndicatorFieldNotFound(getDescriptor(),getDescriptor()));
    }
    if (getClassIndicatorField() != null) {
      setClassIndicatorField(getDescriptor().buildField(getClassIndicatorField()));
      if (shouldUseClassNameAsIndicator()) {
        getClassIndicatorField().setType(ClassConstants.STRING);
      }
 else       if (!getClassIndicatorMapping().isEmpty()) {
        Class type=null;
        Iterator fieldValuesEnum=getClassIndicatorMapping().values().iterator();
        while (fieldValuesEnum.hasNext() && (type == null)) {
          Object value=fieldValuesEnum.next();
          if (value.getClass() != getClass().getClass()) {
            type=value.getClass();
          }
        }
        getClassIndicatorField().setType(type);
      }
      getDescriptor().getFields().addElement(getClassIndicatorField());
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Allow the inheritance properties of the descriptor to be initialized. The descriptor's parent must first be initialized.
 */
public void preInitialize(AbstractSession session) throws DescriptorException {
  if (isChildDescriptor()) {
    updateTables();
    setClassIndicatorMapping(getParentDescriptor().getInheritancePolicy().getClassIndicatorMapping());
    setShouldUseClassNameAsIndicator(getParentDescriptor().getInheritancePolicy().shouldUseClassNameAsIndicator());
    getDescriptor().setPrimaryKeyFields(getParentDescriptor().getPrimaryKeyFields());
    getDescriptor().setAdditionalTablePrimaryKeyFields(Helper.concatenateMaps(getParentDescriptor().getAdditionalTablePrimaryKeyFields(),getDescriptor().getAdditionalTablePrimaryKeyFields()));
    Expression localExpression=getDescriptor().getQueryManager().getMultipleTableJoinExpression();
    Expression parentExpression=getParentDescriptor().getQueryManager().getMultipleTableJoinExpression();
    if (localExpression != null) {
      getDescriptor().getQueryManager().setInternalMultipleTableJoinExpression(localExpression.and(parentExpression));
    }
 else     if (parentExpression != null) {
      getDescriptor().getQueryManager().setInternalMultipleTableJoinExpression(parentExpression);
    }
    Expression localAdditionalExpression=getDescriptor().getQueryManager().getAdditionalJoinExpression();
    Expression parentAdditionalExpression=getParentDescriptor().getQueryManager().getAdditionalJoinExpression();
    if (localAdditionalExpression != null) {
      getDescriptor().getQueryManager().setAdditionalJoinExpression(localAdditionalExpression.and(parentAdditionalExpression));
    }
 else     if (parentAdditionalExpression != null) {
      getDescriptor().getQueryManager().setAdditionalJoinExpression(parentAdditionalExpression);
    }
    setClassIndicatorField(getParentDescriptor().getInheritancePolicy().getClassIndicatorField());
    if (!getDescriptor().usesSequenceNumbers()) {
      getDescriptor().setSequenceNumberField(getParentDescriptor().getSequenceNumberField());
      getDescriptor().setSequenceNumberName(getParentDescriptor().getSequenceNumberName());
    }
  }
 else {
    getDescriptor().setInternalDefaultTable();
  }
  initializeClassExtractor(session);
  if (!isChildDescriptor()) {
    if ((getClassIndicatorField() == null) && (!hasClassExtractor())) {
      session.getIntegrityChecker().handleError(DescriptorException.classIndicatorFieldNotFound(getDescriptor(),getDescriptor()));
    }
    if (getClassIndicatorField() != null) {
      setClassIndicatorField(getDescriptor().buildField(getClassIndicatorField()));
      if (shouldUseClassNameAsIndicator()) {
        getClassIndicatorField().setType(ClassConstants.STRING);
      }
 else       if (!getClassIndicatorMapping().isEmpty()) {
        Class type=null;
        Iterator fieldValuesEnum=getClassIndicatorMapping().values().iterator();
        while (fieldValuesEnum.hasNext() && (type == null)) {
          Object value=fieldValuesEnum.next();
          if (value.getClass() != getClass().getClass()) {
            type=value.getClass();
          }
        }
        getClassIndicatorField().setType(type);
      }
      getDescriptor().getFields().addElement(getClassIndicatorField());
    }
  }
}