Program: 65266
Project: 65266
Buggy source:
public static ComputedColumnHandle generateAggregation(CrosstabReportItemHandle crosstab,AggregationCellHandle cell,MeasureViewHandle measureView,String function,String rowDimension,String rowLevel,String colDimension,String colLevel) throws SemanticException {
  String name=generateComputedColumnName(measureView,colLevel,rowLevel);
  ComputedColumn column=StructureFactory.newComputedColumn(crosstab.getModelHandle(),name);
  String dataType=measureView.getDataType();
  column.setDataType(dataType);
  if (CrosstabUtil.isBoundToLinkedDataSet(crosstab)) {
    String dataField=CrosstabUtil.getRefLinkedDataModelColumnName(measureView);
    if (dataField == null || dataField.isEmpty()) {
      return null;
    }
    column.setExpression(ExpressionUtil.createDataSetRowExpression(dataField));
  }
 else {
    column.setExpression(ExpressionUtil.createJSMeasureExpression(measureView.getCubeMeasureName()));
  }
  String defaultFunction=getDefaultMeasureAggregationFunction(measureView);
  column.setAggregateFunction(function != null ? function : defaultFunction);
  if (function != null && !function.equalsIgnoreCase(defaultFunction)) {
    try {
      IAggrFunction aggFunc=getAggregationManager().getAggregation(column.getAggregateFunction());
      if (aggFunc.getType() == IAggrFunction.RUNNING_AGGR) {
        column.setAggregateFunction(defaultFunction);
      }
 else {
        String targetType=DataAdapterUtil.adapterToModelDataType(aggFunc.getDataType());
        if (!DesignChoiceConstants.COLUMN_DATA_TYPE_ANY.equals(targetType)) {
          column.setDataType(targetType);
        }
      }
    }
 catch (    BirtException e) {
    }
  }
  if (rowLevel != null) {
    column.addAggregateOn(rowLevel);
  }
  if (colLevel != null) {
    column.addAggregateOn(colLevel);
  }
  return ((ReportItemHandle)crosstab.getModelHandle()).addColumnBinding(column,false);
}

Fixed version (ground truth):
public static ComputedColumnHandle generateAggregation(CrosstabReportItemHandle crosstab,AggregationCellHandle cell,MeasureViewHandle measureView,String function,String rowDimension,String rowLevel,String colDimension,String colLevel) throws SemanticException {
  String name=generateComputedColumnName(measureView,colLevel,rowLevel);
  ComputedColumn column=StructureFactory.newComputedColumn(crosstab.getModelHandle(),name);
  String dataType=measureView.getDataType();
  column.setDataType(dataType);
  if (CrosstabUtil.isBoundToLinkedDataSet(crosstab)) {
    String dataField=CrosstabUtil.getRefLinkedDataModelColumnName(measureView);
    if (dataField == null || dataField.trim().length() <= 0) {
      return null;
    }
    column.setExpression(ExpressionUtil.createDataSetRowExpression(dataField));
  }
 else {
    column.setExpression(ExpressionUtil.createJSMeasureExpression(measureView.getCubeMeasureName()));
  }
  String defaultFunction=getDefaultMeasureAggregationFunction(measureView);
  column.setAggregateFunction(function != null ? function : defaultFunction);
  if (function != null && !function.equalsIgnoreCase(defaultFunction)) {
    try {
      IAggrFunction aggFunc=getAggregationManager().getAggregation(column.getAggregateFunction());
      if (aggFunc.getType() == IAggrFunction.RUNNING_AGGR) {
        column.setAggregateFunction(defaultFunction);
      }
 else {
        String targetType=DataAdapterUtil.adapterToModelDataType(aggFunc.getDataType());
        if (!DesignChoiceConstants.COLUMN_DATA_TYPE_ANY.equals(targetType)) {
          column.setDataType(targetType);
        }
      }
    }
 catch (    BirtException e) {
    }
  }
  if (rowLevel != null) {
    column.addAggregateOn(rowLevel);
  }
  if (colLevel != null) {
    column.addAggregateOn(colLevel);
  }
  return ((ReportItemHandle)crosstab.getModelHandle()).addColumnBinding(column,false);
}