Program: 77179
Project: 77179
Buggy source:
/** 
 * populate all output columns in viewer display. The output columns is retrieved from oda dataset handles's RESULT_SET_PROP and COMPUTED_COLUMNS_PROP.
 * @throws BirtException
 */
public static IResultMetaData retrieveResultMetaData(DataSetHandle dataSetHandle) throws BirtException {
  List resultSetList=null;
  if (dataSetHandle instanceof OdaDataSetHandle) {
    resultSetList=(List)dataSetHandle.getProperty(OdaDataSetHandle.RESULT_SET_PROP);
  }
 else {
    return null;
  }
  List computedList=(List)dataSetHandle.getProperty(OdaDataSetHandle.COMPUTED_COLUMNS_PROP);
  List columnMeta=new ArrayList();
  ResultSetColumnDefinition columnDef;
  int count=0;
  if (resultSetList != null) {
    ResultSetColumn resultSetColumn;
    HashSet orgColumnNameSet=new HashSet();
    HashSet uniqueColumnNameSet=new HashSet();
    for (int n=0; n < resultSetList.size(); n++) {
      orgColumnNameSet.add(((ResultSetColumn)resultSetList.get(n)).getColumnName());
    }
    for (int i=0; i < resultSetList.size(); i++) {
      resultSetColumn=(ResultSetColumn)resultSetList.get(i);
      String columnName=resultSetColumn.getColumnName();
      String uniqueColumnName=getUniqueName(orgColumnNameSet,uniqueColumnNameSet,columnName,i);
      uniqueColumnNameSet.add(uniqueColumnName);
      if (!uniqueColumnName.equals(columnName)) {
        updateModelColumn(dataSetHandle,uniqueColumnName,i + 1);
      }
      columnDef=new ResultSetColumnDefinition(uniqueColumnName);
      columnDef.setDataTypeName(resultSetColumn.getDataType());
      columnDef.setDataType(ModelAdapter.adaptModelDataType(resultSetColumn.getDataType()));
      if (resultSetColumn.getPosition() != null)       columnDef.setColumnPosition(resultSetColumn.getPosition().intValue());
      if (resultSetColumn.getNativeDataType() != null)       columnDef.setNativeDataType(resultSetColumn.getNativeDataType().intValue());
      if (findColumnHint(dataSetHandle,uniqueColumnName) != null) {
        ColumnHintHandle columnHint=findColumnHint(dataSetHandle,resultSetColumn.getColumnName());
        columnDef.setAlias(columnHint.getAlias());
        columnDef.setLableName(columnHint.getDisplayName());
      }
      columnDef.setComputedColumn(false);
      columnMeta.add(columnDef);
    }
    count+=resultSetList.size();
    if (computedList != null) {
      for (int n=0; n < computedList.size(); n++) {
        orgColumnNameSet.add(((ComputedColumn)computedList.get(n)).getName());
      }
      ComputedColumn computedColumn;
      for (int i=0; i < computedList.size(); i++) {
        computedColumn=(ComputedColumn)computedList.get(i);
        String columnName=computedColumn.getName();
        String uniqueColumnName=getUniqueName(orgColumnNameSet,uniqueColumnNameSet,columnName,i + count);
        uniqueColumnNameSet.add(uniqueColumnName);
        if (!uniqueColumnName.equals(columnName)) {
          updateComputedColumn(dataSetHandle,uniqueColumnName,columnName);
        }
        columnDef=new ResultSetColumnDefinition(uniqueColumnName);
        columnDef.setDataTypeName(computedColumn.getDataType());
        columnDef.setDataType(ModelAdapter.adaptModelDataType(computedColumn.getDataType()));
        if (findColumnHint(dataSetHandle,computedColumn.getName()) != null) {
          ColumnHintHandle columnHint=findColumnHint(dataSetHandle,uniqueColumnName);
          columnDef.setAlias(columnHint.getAlias());
          columnDef.setLableName(columnHint.getDisplayName());
        }
        columnDef.setComputedColumn(true);
        columnMeta.add(columnDef);
      }
    }
    return new ResultMetaData2(columnMeta);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * populate all output columns in viewer display. The output columns is retrieved from oda dataset handles's RESULT_SET_PROP and COMPUTED_COLUMNS_PROP.
 * @throws BirtException
 */
public static IResultMetaData retrieveResultMetaData(DataSetHandle dataSetHandle) throws BirtException {
  List resultSetList=null;
  if (dataSetHandle instanceof OdaDataSetHandle) {
    resultSetList=(List)dataSetHandle.getProperty(OdaDataSetHandle.RESULT_SET_PROP);
  }
 else {
    return null;
  }
  List computedList=(List)dataSetHandle.getProperty(OdaDataSetHandle.COMPUTED_COLUMNS_PROP);
  List columnMeta=new ArrayList();
  ResultSetColumnDefinition columnDef;
  int count=0;
  if (resultSetList != null) {
    ResultSetColumn resultSetColumn;
    HashSet orgColumnNameSet=new HashSet();
    HashSet uniqueColumnNameSet=new HashSet();
    for (int n=0; n < resultSetList.size(); n++) {
      orgColumnNameSet.add(((ResultSetColumn)resultSetList.get(n)).getColumnName());
    }
    for (int i=0; i < resultSetList.size(); i++) {
      resultSetColumn=(ResultSetColumn)resultSetList.get(i);
      String columnName=resultSetColumn.getColumnName();
      String uniqueColumnName=getUniqueName(orgColumnNameSet,uniqueColumnNameSet,columnName,i);
      uniqueColumnNameSet.add(uniqueColumnName);
      if (!uniqueColumnName.equals(columnName)) {
        updateModelColumn(dataSetHandle,uniqueColumnName,i + 1);
      }
      columnDef=new ResultSetColumnDefinition(uniqueColumnName);
      columnDef.setDataTypeName(resultSetColumn.getDataType());
      columnDef.setDataType(ModelAdapter.adaptModelDataType(resultSetColumn.getDataType()));
      if (resultSetColumn.getPosition() != null)       columnDef.setColumnPosition(resultSetColumn.getPosition().intValue());
      if (resultSetColumn.getNativeDataType() != null)       columnDef.setNativeDataType(resultSetColumn.getNativeDataType().intValue());
      if (findColumnHint(dataSetHandle,uniqueColumnName) != null) {
        ColumnHintHandle columnHint=findColumnHint(dataSetHandle,uniqueColumnName);
        columnDef.setAlias(columnHint.getAlias());
        columnDef.setLableName(columnHint.getDisplayName());
      }
      columnDef.setComputedColumn(false);
      columnMeta.add(columnDef);
    }
    count+=resultSetList.size();
    if (computedList != null) {
      for (int n=0; n < computedList.size(); n++) {
        orgColumnNameSet.add(((ComputedColumn)computedList.get(n)).getName());
      }
      ComputedColumn computedColumn;
      for (int i=0; i < computedList.size(); i++) {
        computedColumn=(ComputedColumn)computedList.get(i);
        String columnName=computedColumn.getName();
        String uniqueColumnName=getUniqueName(orgColumnNameSet,uniqueColumnNameSet,columnName,i + count);
        uniqueColumnNameSet.add(uniqueColumnName);
        if (!uniqueColumnName.equals(columnName)) {
          updateComputedColumn(dataSetHandle,uniqueColumnName,columnName);
        }
        columnDef=new ResultSetColumnDefinition(uniqueColumnName);
        columnDef.setDataTypeName(computedColumn.getDataType());
        columnDef.setDataType(ModelAdapter.adaptModelDataType(computedColumn.getDataType()));
        if (findColumnHint(dataSetHandle,uniqueColumnName) != null) {
          ColumnHintHandle columnHint=findColumnHint(dataSetHandle,uniqueColumnName);
          columnDef.setAlias(columnHint.getAlias());
          columnDef.setLableName(columnHint.getDisplayName());
        }
        columnDef.setComputedColumn(true);
        columnMeta.add(columnDef);
      }
    }
    return new ResultMetaData2(columnMeta);
  }
  return null;
}