Program: 72322
Project: 72322
Buggy source:
/** 
 * Computes row span for aggreagtion cell by given target span over dimension and level.
 * @param crosstabItem
 * @param rowGroups
 * @param targetDimensionIndex
 * @param targetLevelIndex
 * @param rowEdgeCursor
 * @return
 * @throws OLAPException
 */
public static int computeAggregationCellRowOverSpan(CrosstabReportItemHandle crosstabItem,List rowGroups,LevelHandle targetSpanLevel,EdgeCursor rowEdgeCursor) throws OLAPException {
  if (rowEdgeCursor == null || targetSpanLevel == null) {
    return 1;
  }
  long startPosition=rowEdgeCursor.getPosition();
  int targetGroupIndex=getGroupIndex(rowGroups,targetSpanLevel);
  boolean verticalHeader=MEASURE_DIRECTION_VERTICAL.equals(crosstabItem.getMeasureDirection());
  int factor=verticalHeader ? Math.max(crosstabItem.getMeasureCount(),1) : 1;
  if (targetGroupIndex != -1) {
    long currentPosition=startPosition;
    long edgeEndPosition;
    DimensionCursor dc;
    if (targetGroupIndex > 0) {
      dc=(DimensionCursor)rowEdgeCursor.getDimensionCursor().get(targetGroupIndex - 1);
      edgeEndPosition=dc.getEdgeEnd();
    }
 else {
      edgeEndPosition=Long.MAX_VALUE;
    }
    int span=0;
    while (currentPosition <= edgeEndPosition && !rowEdgeCursor.isAfterLast()) {
      span+=factor;
      for (int i=rowGroups.size() - 2; i >= targetGroupIndex; i--) {
        dc=(DimensionCursor)rowEdgeCursor.getDimensionCursor().get(i);
        if (isDummyGroup(dc)) {
          continue;
        }
        if (currentPosition == dc.getEdgeEnd()) {
          EdgeGroup gp=(EdgeGroup)rowGroups.get(i);
          DimensionViewHandle dv=crosstabItem.getDimension(ROW_AXIS_TYPE,gp.dimensionIndex);
          LevelViewHandle lv=dv.getLevel(gp.levelIndex);
          if (lv.getAggregationHeader() != null) {
            span+=getTotalRowSpan(crosstabItem,gp.dimensionIndex,gp.levelIndex,verticalHeader);
          }
        }
 else {
          break;
        }
      }
      rowEdgeCursor.next();
      currentPosition=rowEdgeCursor.getPosition();
    }
    rowEdgeCursor.setPosition(startPosition);
    return span;
  }
  return factor;
}

Fixed version (ground truth):
/** 
 * Computes row span for aggreagtion cell by given target span over dimension and level.
 * @param crosstabItem
 * @param rowGroups
 * @param targetDimensionIndex
 * @param targetLevelIndex
 * @param rowEdgeCursor
 * @return
 * @throws OLAPException
 */
public static int computeAggregationCellRowOverSpan(CrosstabReportItemHandle crosstabItem,List<EdgeGroup> rowGroups,LevelHandle targetSpanLevel,EdgeCursor rowEdgeCursor) throws OLAPException {
  if (rowEdgeCursor == null || targetSpanLevel == null) {
    return 1;
  }
  long startPosition=rowEdgeCursor.getPosition();
  int targetGroupIndex=getGroupIndex(rowGroups,targetSpanLevel);
  boolean verticalHeader=MEASURE_DIRECTION_VERTICAL.equals(crosstabItem.getMeasureDirection());
  int factor=verticalHeader ? Math.max(crosstabItem.getMeasureCount(),1) : 1;
  if (targetGroupIndex != -1) {
    long currentPosition=startPosition;
    long edgeEndPosition;
    DimensionCursor dc;
    if (targetGroupIndex > 0) {
      dc=(DimensionCursor)rowEdgeCursor.getDimensionCursor().get(targetGroupIndex - 1);
      edgeEndPosition=dc.getEdgeEnd();
    }
 else {
      edgeEndPosition=Long.MAX_VALUE;
    }
    int span=0;
    while (currentPosition <= edgeEndPosition && !rowEdgeCursor.isAfterLast()) {
      span+=factor;
      for (int i=rowGroups.size() - 2; i >= targetGroupIndex; i--) {
        dc=(DimensionCursor)rowEdgeCursor.getDimensionCursor().get(i);
        if (isDummyGroup(dc)) {
          continue;
        }
        if (currentPosition == dc.getEdgeEnd()) {
          EdgeGroup gp=rowGroups.get(i);
          DimensionViewHandle dv=crosstabItem.getDimension(ROW_AXIS_TYPE,gp.dimensionIndex);
          LevelViewHandle lv=dv.getLevel(gp.levelIndex);
          if (lv.getAggregationHeader() != null) {
            span+=getTotalRowSpan(crosstabItem,gp.dimensionIndex,gp.levelIndex,verticalHeader);
          }
        }
 else {
          break;
        }
      }
      rowEdgeCursor.next();
      currentPosition=rowEdgeCursor.getPosition();
    }
    rowEdgeCursor.setPosition(startPosition);
    return span;
  }
  return factor;
}