Program: 76478
Project: 76478
Buggy source:
/** 
 * Adjusts the measure aggregations when row/column dimension or level is changed.
 * @param crosstab
 * @param axisType the axis type where the dimension or level is changed or the grand total is changed
 * @param dimensionName
 * @param levelName
 * @param isLevelInnerMost
 * @param isAdd
 * @throws SemanticException
 */
private static void addMeasureAggregations(CrosstabReportItemHandle crosstab,int axisType,LevelViewHandle theLevelView,String dimensionName,String levelName,boolean isInnerMost,List functions,List measures,boolean checkCounterMeasureList) throws SemanticException {
  if (crosstab == null || measures == null || measures.isEmpty() || !isValidAxisType(axisType))   return;
  int counterAxisType=getOppositeAxisType(axisType);
  boolean isCounterAxisEmpty=true;
  for (int dimension=0; dimension < crosstab.getDimensionCount(counterAxisType); dimension++) {
    DimensionViewHandle dimensionView=crosstab.getDimension(counterAxisType,dimension);
    for (int level=0; level < dimensionView.getLevelCount(); level++) {
      isCounterAxisEmpty=false;
      LevelViewHandle levelView=dimensionView.getLevel(level);
      String rowDimension=null;
      String rowLevel=null;
      String colDimension=null;
      String colLevel=null;
      if (counterAxisType == ROW_AXIS_TYPE) {
        rowDimension=dimensionView.getCubeDimensionName();
        rowLevel=levelView.getCubeLevelName();
        colDimension=dimensionName;
        colLevel=levelName;
      }
 else       if (counterAxisType == COLUMN_AXIS_TYPE) {
        rowDimension=dimensionName;
        rowLevel=levelName;
        colDimension=dimensionView.getCubeDimensionName();
        colLevel=levelView.getCubeLevelName();
      }
      if ((isInnerMost && !levelView.isInnerMost() && levelView.getAggregationHeader() != null) || (!isInnerMost && (levelView.isInnerMost() || levelView.getAggregationHeader() != null))) {
        for (int i=0; i < measures.size(); i++) {
          MeasureViewHandle measureView=(MeasureViewHandle)measures.get(i);
          String function=functions == null ? null : (String)functions.get(i);
          if (measureView.getCrosstab() != crosstab)           continue;
          if (checkCounterMeasureList && !isAggregationOn(measureView,levelView.getCubeLevelName(),counterAxisType))           continue;
          addDataItem(crosstab,measureView,function,rowDimension,rowLevel,colDimension,colLevel);
        }
      }
    }
  }
  if (crosstab.getGrandTotal(counterAxisType) != null || (isCounterAxisEmpty && (theLevelView == null || theLevelView.getAggregationHeader() != null))) {
    String rowDimension=null;
    String rowLevel=null;
    String colDimension=null;
    String colLevel=null;
    if (counterAxisType == ROW_AXIS_TYPE) {
      colDimension=dimensionName;
      colLevel=levelName;
    }
 else     if (counterAxisType == COLUMN_AXIS_TYPE) {
      rowDimension=dimensionName;
      rowLevel=levelName;
    }
    for (int i=0; i < measures.size(); i++) {
      MeasureViewHandle measureView=(MeasureViewHandle)measures.get(i);
      if (measureView.getCrosstab() != crosstab)       continue;
      String function=functions == null ? null : (String)functions.get(i);
      if (checkCounterMeasureList && !isAggregationOn(measureView,null,counterAxisType))       continue;
      addDataItem(crosstab,measureView,function,rowDimension,rowLevel,colDimension,colLevel);
    }
  }
}

Fixed version (ground truth):
/** 
 * Adjusts the measure aggregations when row/column dimension or level is changed.
 * @param crosstab
 * @param axisType the axis type where the dimension or level is changed or the grand total is changed
 * @param dimensionName
 * @param levelName
 * @param isLevelInnerMost
 * @param isAdd
 * @throws SemanticException
 */
private static void addMeasureAggregations(CrosstabReportItemHandle crosstab,int axisType,LevelViewHandle theLevelView,String dimensionName,String levelName,boolean isInnerMost,List functions,List measures,boolean checkCounterMeasureList) throws SemanticException {
  if (crosstab == null || measures == null || measures.isEmpty() || !isValidAxisType(axisType))   return;
  int counterAxisType=getOppositeAxisType(axisType);
  boolean isCounterAxisEmpty=true;
  for (int dimension=0; dimension < crosstab.getDimensionCount(counterAxisType); dimension++) {
    DimensionViewHandle dimensionView=crosstab.getDimension(counterAxisType,dimension);
    for (int level=0; level < dimensionView.getLevelCount(); level++) {
      isCounterAxisEmpty=false;
      LevelViewHandle levelView=dimensionView.getLevel(level);
      String rowDimension=null;
      String rowLevel=null;
      String colDimension=null;
      String colLevel=null;
      if (counterAxisType == ROW_AXIS_TYPE) {
        rowDimension=dimensionView.getCubeDimensionName();
        rowLevel=levelView.getCubeLevelName();
        colDimension=dimensionName;
        colLevel=levelName;
      }
 else       if (counterAxisType == COLUMN_AXIS_TYPE) {
        rowDimension=dimensionName;
        rowLevel=levelName;
        colDimension=dimensionView.getCubeDimensionName();
        colLevel=levelView.getCubeLevelName();
      }
      if ((isInnerMost && !levelView.isInnerMost() && levelView.getAggregationHeader() != null) || (!isInnerMost && (theLevelView == null || theLevelView.getAggregationHeader() != null) && (levelView.isInnerMost() || levelView.getAggregationHeader() != null))) {
        for (int i=0; i < measures.size(); i++) {
          MeasureViewHandle measureView=(MeasureViewHandle)measures.get(i);
          String function=functions == null ? null : (String)functions.get(i);
          if (measureView.getCrosstab() != crosstab)           continue;
          if (checkCounterMeasureList && !isAggregationOn(measureView,levelView.getCubeLevelName(),counterAxisType))           continue;
          addDataItem(crosstab,measureView,function,rowDimension,rowLevel,colDimension,colLevel);
        }
      }
    }
  }
  if (crosstab.getGrandTotal(counterAxisType) != null || (isCounterAxisEmpty && (theLevelView == null || theLevelView.getAggregationHeader() != null))) {
    String rowDimension=null;
    String rowLevel=null;
    String colDimension=null;
    String colLevel=null;
    if (counterAxisType == ROW_AXIS_TYPE) {
      colDimension=dimensionName;
      colLevel=levelName;
    }
 else     if (counterAxisType == COLUMN_AXIS_TYPE) {
      rowDimension=dimensionName;
      rowLevel=levelName;
    }
    for (int i=0; i < measures.size(); i++) {
      MeasureViewHandle measureView=(MeasureViewHandle)measures.get(i);
      if (measureView.getCrosstab() != crosstab)       continue;
      String function=functions == null ? null : (String)functions.get(i);
      if (checkCounterMeasureList && !isAggregationOn(measureView,null,counterAxisType))       continue;
      addDataItem(crosstab,measureView,function,rowDimension,rowLevel,colDimension,colLevel);
    }
  }
}