Program: 66310
Project: 66310
Buggy source:
public static List<ComputedColumn> generateComputedColumns(ExtendedItemHandle itemHandle,CubeHandle cubeHandle){
  if (cubeHandle != null) {
    List<ComputedColumn> columnList=new ArrayList<ComputedColumn>();
    String exprType=UIUtil.getDefaultScriptType();
    IExpressionConverter exprConverter=ExpressionUtility.getExpressionConverter(exprType);
    for (    LevelHandle levelHandle : ChartCubeUtil.getAllLevels(cubeHandle)) {
      String displayNameAttr=null;
      String dataType=levelHandle.getDataType();
      if (levelHandle instanceof TabularLevelHandle && ((TabularLevelHandle)levelHandle).getDisplayColumnName() != null && ((TabularLevelHandle)levelHandle).getDisplayColumnName().trim().length() > 0) {
        displayNameAttr=ICubeQueryUtil.DISPLAY_NAME_ATTR;
        dataType=DesignChoiceConstants.COLUMN_DATA_TYPE_STRING;
      }
      ComputedColumn column=StructureFactory.newComputedColumn(itemHandle,ChartCubeUtil.createLevelBindingName(levelHandle));
      column.setDataType(dataType);
      column.setExpressionProperty(ComputedColumn.EXPRESSION_MEMBER,new Expression(exprConverter.getDimensionExpression(levelHandle.getContainer().getContainer().getName(),levelHandle.getName(),displayNameAttr),exprType));
      columnList.add(column);
      Iterator itLevelAttr=levelHandle.attributesIterator();
      while (itLevelAttr.hasNext()) {
        LevelAttributeHandle laHandle=(LevelAttributeHandle)itLevelAttr.next();
        ComputedColumn columnLA=StructureFactory.newComputedColumn(itemHandle,ChartCubeUtil.createLevelAttrBindingName(levelHandle,laHandle));
        columnLA.setDataType(laHandle.getDataType());
        columnLA.setExpressionProperty(ComputedColumn.EXPRESSION_MEMBER,new Expression(exprConverter.getDimensionExpression(levelHandle.getContainer().getContainer().getName(),levelHandle.getName(),laHandle.getName()),exprType));
        columnList.add(columnLA);
      }
    }
    for (    MeasureHandle measureHandle : ChartCubeUtil.getAllMeasures(cubeHandle)) {
      ComputedColumn column=StructureFactory.newComputedColumn(itemHandle,ChartCubeUtil.createMeasureBindingName(measureHandle));
      column.setDataType(measureHandle.getDataType());
      column.setExpressionProperty(ComputedColumn.EXPRESSION_MEMBER,new Expression(exprConverter.getMeasureExpression(measureHandle.getName()),exprType));
      column.setAggregateFunction(DataAdapterUtil.getRollUpAggregationName(measureHandle.getFunction()));
      columnList.add(column);
    }
    return columnList;
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
public static List<ComputedColumn> generateComputedColumns(ExtendedItemHandle itemHandle,CubeHandle cubeHandle){
  if (cubeHandle != null) {
    Set<String> bindingNameSet=new HashSet<String>();
    List<ComputedColumn> columnList=new ArrayList<ComputedColumn>();
    String exprType=UIUtil.getDefaultScriptType();
    IExpressionConverter exprConverter=ExpressionUtility.getExpressionConverter(exprType);
    for (    LevelHandle levelHandle : ChartCubeUtil.getAllLevels(cubeHandle)) {
      String displayNameAttr=null;
      String dataType=levelHandle.getDataType();
      if (levelHandle instanceof TabularLevelHandle && ((TabularLevelHandle)levelHandle).getDisplayColumnName() != null && ((TabularLevelHandle)levelHandle).getDisplayColumnName().trim().length() > 0) {
        displayNameAttr=ICubeQueryUtil.DISPLAY_NAME_ATTR;
        dataType=DesignChoiceConstants.COLUMN_DATA_TYPE_STRING;
      }
      ComputedColumn column=StructureFactory.newComputedColumn(itemHandle,ChartCubeUtil.createLevelBindingName(levelHandle));
      column.setDataType(dataType);
      column.setExpressionProperty(ComputedColumn.EXPRESSION_MEMBER,new Expression(exprConverter.getDimensionExpression(levelHandle.getContainer().getContainer().getName(),levelHandle.getName(),displayNameAttr),exprType));
      correctBindingName(column,bindingNameSet);
      columnList.add(column);
      Iterator itLevelAttr=levelHandle.attributesIterator();
      while (itLevelAttr.hasNext()) {
        LevelAttributeHandle laHandle=(LevelAttributeHandle)itLevelAttr.next();
        ComputedColumn columnLA=StructureFactory.newComputedColumn(itemHandle,ChartCubeUtil.createLevelAttrBindingName(levelHandle,laHandle));
        columnLA.setDataType(laHandle.getDataType());
        columnLA.setExpressionProperty(ComputedColumn.EXPRESSION_MEMBER,new Expression(exprConverter.getDimensionExpression(levelHandle.getContainer().getContainer().getName(),levelHandle.getName(),laHandle.getName()),exprType));
        correctBindingName(columnLA,bindingNameSet);
        columnList.add(columnLA);
      }
    }
    for (    MeasureHandle measureHandle : ChartCubeUtil.getAllMeasures(cubeHandle)) {
      ComputedColumn column=StructureFactory.newComputedColumn(itemHandle,ChartCubeUtil.createMeasureBindingName(measureHandle));
      column.setDataType(measureHandle.getDataType());
      column.setExpressionProperty(ComputedColumn.EXPRESSION_MEMBER,new Expression(exprConverter.getMeasureExpression(measureHandle.getName()),exprType));
      column.setAggregateFunction(DataAdapterUtil.getRollUpAggregationName(measureHandle.getFunction()));
      correctBindingName(column,bindingNameSet);
      columnList.add(column);
    }
    return columnList;
  }
  return Collections.emptyList();
}