Program: 72146
Project: 72146
Buggy source:
private void handleColumnPageBreak(ColumnEvent event,IColumn col) throws OLAPException {
  columnCursor.setPosition(event.dataPosition);
  if (event.type == ColumnEvent.COLUMN_TOTAL_CHANGE) {
    int currentGroupIndex=GroupUtil.getGroupIndex(columnGroups,event.dimensionIndex,event.levelIndex);
    if (event.isLocationBefore) {
      boolean isFirst=((DimensionCursor)groupCursors.get(currentGroupIndex)).isFirst();
      if (pageBreakBeforeInts[currentGroupIndex] == 1 || (pageBreakBeforeInts[currentGroupIndex] == 2 && !isFirst)) {
        col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
      }
      if (notifyNextPageBreak != -1) {
        notifyNextPageBreak=-1;
        col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
      }
    }
 else {
      if (pageBreakAfterInts[currentGroupIndex] == 1) {
        col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_AFTER,IStyle.ALWAYS_VALUE);
      }
 else       if (pageBreakAfterInts[currentGroupIndex] == 2) {
        boolean isLast=((DimensionCursor)groupCursors.get(currentGroupIndex)).isLast();
        if (!isLast) {
          notifyNextPageBreak=currentGroupIndex;
        }
      }
    }
  }
 else   if (event.type == ColumnEvent.COLUMN_EDGE_CHANGE) {
    int startingGrouplevel=GroupUtil.getStartingGroupLevel(columnCursor,groupCursors);
    int startBound=startingGrouplevel == 0 ? 0 : (startingGrouplevel - 1);
    for (int i=startBound; i < pageBreakBeforeInts.length; i++) {
      if (!hasTotalBefore[i]) {
        if (pageBreakBeforeInts[i] == 1) {
          col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
          break;
        }
 else         if (pageBreakBeforeInts[i] == 2) {
          boolean isFirst=((DimensionCursor)groupCursors.get(i)).isFirst();
          if (!isFirst) {
            col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
            break;
          }
        }
      }
    }
    if (notifyNextPageBreak != -1 && (startingGrouplevel <= notifyNextPageBreak + 1)) {
      notifyNextPageBreak=-1;
      col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
    }
    int endingGroupLevel=GroupUtil.getEndingGroupLevel(columnCursor,groupCursors);
    int endBound=endingGroupLevel == 0 ? 0 : (endingGroupLevel - 1);
    for (int i=endBound; i < pageBreakAfterInts.length; i++) {
      if (!hasTotalAfter[i]) {
        if (pageBreakAfterInts[i] == 1) {
          col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_AFTER,IStyle.ALWAYS_VALUE);
        }
 else         if (pageBreakAfterInts[i] == 2) {
          boolean isLast=((DimensionCursor)groupCursors.get(i)).isLast();
          if (!isLast) {
            notifyNextPageBreak=i;
          }
        }
      }
    }
  }
 else   if (event.type == ColumnEvent.GRAND_TOTAL_CHANGE) {
    if (notifyNextPageBreak != -1) {
      notifyNextPageBreak=-1;
      col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
    }
  }
}

Fixed version (ground truth):
private void handleColumnPageBreak(ColumnEvent event,IColumn col) throws OLAPException {
  columnCursor.setPosition(event.dataPosition);
  if (event.type == ColumnEvent.COLUMN_TOTAL_CHANGE) {
    int currentGroupIndex=GroupUtil.getGroupIndex(columnGroups,event.dimensionIndex,event.levelIndex);
    if (event.isLocationBefore) {
      if (event.measureIndex == -1 || event.measureIndex == firstTotalMeasureIndex[currentGroupIndex]) {
        boolean isFirst=((DimensionCursor)groupCursors.get(currentGroupIndex)).isFirst();
        if (pageBreakBeforeInts[currentGroupIndex] == 1 || (pageBreakBeforeInts[currentGroupIndex] == 2 && !isFirst)) {
          col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
        }
        if (notifyNextPageBreak != -1) {
          notifyNextPageBreak=-1;
          col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
        }
      }
    }
 else {
      if (event.measureIndex == -1 || event.measureIndex == lastTotalMeasureIndex[currentGroupIndex]) {
        if (pageBreakAfterInts[currentGroupIndex] == 1) {
          col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_AFTER,IStyle.ALWAYS_VALUE);
        }
 else         if (pageBreakAfterInts[currentGroupIndex] == 2) {
          boolean isLast=((DimensionCursor)groupCursors.get(currentGroupIndex)).isLast();
          if (!isLast) {
            notifyNextPageBreak=currentGroupIndex;
          }
        }
      }
    }
  }
 else   if (event.type == ColumnEvent.COLUMN_EDGE_CHANGE) {
    if (event.measureIndex == -1 || event.measureIndex == 0) {
      int startingGrouplevel=GroupUtil.getStartingGroupLevel(columnCursor,groupCursors);
      int startBound=startingGrouplevel == 0 ? 0 : (startingGrouplevel - 1);
      for (int i=startBound; i < pageBreakBeforeInts.length; i++) {
        if (!hasTotalBefore[i]) {
          if (pageBreakBeforeInts[i] == 1) {
            col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
            break;
          }
 else           if (pageBreakBeforeInts[i] == 2) {
            boolean isFirst=((DimensionCursor)groupCursors.get(i)).isFirst();
            if (!isFirst) {
              col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
              break;
            }
          }
        }
      }
      if (notifyNextPageBreak != -1 && (startingGrouplevel <= notifyNextPageBreak + 1)) {
        notifyNextPageBreak=-1;
        col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
      }
    }
    if (event.measureIndex == -1 || event.measureIndex == lastMeasureIndex) {
      int endingGroupLevel=GroupUtil.getEndingGroupLevel(columnCursor,groupCursors);
      int endBound=endingGroupLevel == 0 ? 0 : (endingGroupLevel - 1);
      for (int i=endBound; i < pageBreakAfterInts.length; i++) {
        if (!hasTotalAfter[i]) {
          if (pageBreakAfterInts[i] == 1) {
            col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_AFTER,IStyle.ALWAYS_VALUE);
          }
 else           if (pageBreakAfterInts[i] == 2) {
            boolean isLast=((DimensionCursor)groupCursors.get(i)).isLast();
            if (!isLast) {
              notifyNextPageBreak=i;
            }
          }
        }
      }
    }
  }
 else   if (event.type == ColumnEvent.GRAND_TOTAL_CHANGE) {
    if (event.measureIndex == -1 || event.measureIndex == firstGrandTotalMeasureIndex) {
      if (notifyNextPageBreak != -1) {
        notifyNextPageBreak=-1;
        col.getStyle().setProperty(IStyle.STYLE_PAGE_BREAK_BEFORE,IStyle.ALWAYS_VALUE);
      }
    }
  }
}