Program: 75997
Project: 75997
Buggy source:
/** 
 * Returns if aggregation is defined on given level on specific axis
 * @param measureView
 * @param levelView
 * @param axisType
 * @return
 */
protected boolean isAggregationDefined(MeasureViewHandle measureView,LevelViewHandle levelView,int axisType){
  if (measureView != null) {
    String checkDimensionName=null;
    String checkLevelName=null;
    if (levelView != null) {
      checkDimensionName=((DimensionViewHandle)levelView.getContainer()).getCubeDimensionName();
      checkLevelName=levelView.getCubeLevelName();
    }
    if (axisType == ROW_AXIS_TYPE) {
      int totalColDimensions=crosstab.getDimensionCount(COLUMN_AXIS_TYPE);
      if (totalColDimensions > 0) {
        for (int i=0; i < totalColDimensions; i++) {
          DimensionViewHandle dv=crosstab.getDimension(COLUMN_AXIS_TYPE,i);
          int totalLevels=dv.getLevelCount();
          for (int j=0; j < totalLevels; j++) {
            LevelViewHandle lv=dv.getLevel(j);
            if ((i == totalColDimensions - 1 && j == totalLevels - 1) || lv.getAggregationHeader() != null) {
              AggregationCellHandle cell=measureView.getAggregationCell(checkDimensionName,checkLevelName,dv.getCubeDimensionName(),lv.getCubeLevelName());
              if (cell != null) {
                return true;
              }
            }
          }
        }
      }
      if (totalColDimensions == 0 || crosstab.getGrandTotal(COLUMN_AXIS_TYPE) != null) {
        AggregationCellHandle cell=measureView.getAggregationCell(checkDimensionName,checkLevelName,null,null);
        if (cell != null) {
          return true;
        }
      }
    }
 else     if (axisType == COLUMN_AXIS_TYPE) {
      int totalRowDimensions=crosstab.getDimensionCount(ROW_AXIS_TYPE);
      if (totalRowDimensions > 0) {
        for (int i=0; i < totalRowDimensions; i++) {
          DimensionViewHandle dv=crosstab.getDimension(ROW_AXIS_TYPE,i);
          int totalLevels=dv.getLevelCount();
          for (int j=0; j < totalLevels; j++) {
            LevelViewHandle lv=dv.getLevel(j);
            if ((i == totalRowDimensions - 1 && j == totalLevels - 1) || lv.getAggregationHeader() != null) {
              AggregationCellHandle cell=measureView.getAggregationCell(dv.getCubeDimensionName(),lv.getCubeLevelName(),checkDimensionName,checkLevelName);
              if (cell != null) {
                return true;
              }
            }
          }
        }
      }
      if (totalRowDimensions == 0 || crosstab.getGrandTotal(ROW_AXIS_TYPE) != null) {
        AggregationCellHandle cell=measureView.getAggregationCell(null,null,checkDimensionName,checkLevelName);
        if (cell != null) {
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns if aggregation is defined on given level on specific axis
 * @param measureView
 * @param levelView
 * @param axisType
 * @return
 */
protected boolean isAggregationDefined(MeasureViewHandle measureView,LevelViewHandle levelView,int axisType,List counterAggregationLevels){
  if (measureView != null) {
    String checkDimensionName=null;
    String checkLevelName=null;
    if (levelView != null) {
      checkDimensionName=((DimensionViewHandle)levelView.getContainer()).getCubeDimensionName();
      checkLevelName=levelView.getCubeLevelName();
    }
    int counterAxisType=CrosstabModelUtil.getOppositeAxisType(axisType);
    boolean isInnerMost=levelView != null ? levelView.isInnerMost() : false;
    if (isInnerMost) {
      if (counterAggregationLevels.size() > 0) {
        return true;
      }
      if (crosstab.getGrandTotal(counterAxisType) != null) {
        return true;
      }
    }
    int totalDimensions=crosstab.getDimensionCount(counterAxisType);
    if (totalDimensions > 0) {
      for (int i=0; i < totalDimensions; i++) {
        DimensionViewHandle dv=crosstab.getDimension(counterAxisType,i);
        int totalLevels=dv.getLevelCount();
        for (int j=0; j < totalLevels; j++) {
          LevelViewHandle lv=dv.getLevel(j);
          if ((i == totalDimensions - 1 && j == totalLevels - 1) || lv.getAggregationHeader() != null) {
            AggregationCellHandle cell=null;
            if (axisType == ROW_AXIS_TYPE) {
              cell=measureView.getAggregationCell(checkDimensionName,checkLevelName,dv.getCubeDimensionName(),lv.getCubeLevelName());
            }
 else {
              cell=measureView.getAggregationCell(dv.getCubeDimensionName(),lv.getCubeLevelName(),checkDimensionName,checkLevelName);
            }
            if (cell != null) {
              return true;
            }
          }
        }
      }
    }
    if (totalDimensions == 0 || crosstab.getGrandTotal(counterAxisType) != null) {
      AggregationCellHandle cell=null;
      if (axisType == ROW_AXIS_TYPE) {
        cell=measureView.getAggregationCell(checkDimensionName,checkLevelName,null,null);
      }
 else {
        cell=measureView.getAggregationCell(null,null,checkDimensionName,checkLevelName);
      }
      if (cell != null) {
        return true;
      }
    }
  }
  return false;
}