Program: 76106
Project: 76106
Buggy source:
public IReportItemExecutor getNextChild(){
  IReportItemExecutor nextExecutor=null;
  try {
    while (walker.hasNext()) {
      ColumnEvent ev=walker.next();
switch (currentChangeType) {
case ColumnEvent.ROW_EDGE_CHANGE:
        if (ev.type != ColumnEvent.ROW_EDGE_CHANGE && rowIndex == 0) {
          nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getGrandTotal(ROW_AXIS_TYPE),rowSpan,colSpan,currentColIndex - colSpan + 1);
          hasLast=false;
        }
      break;
case ColumnEvent.MEASURE_HEADER_CHANGE:
    nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
  hasLast=false;
break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
int mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowGrandTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
hasLast=false;
break;
}
if (ev.type == ColumnEvent.MEASURE_CHANGE || ev.type == ColumnEvent.COLUMN_EDGE_CHANGE) {
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
if (columnGroups != null && columnGroups.size() > 0) {
EdgeGroup gp=(EdgeGroup)columnGroups.get(columnGroups.size() - 1);
lastDimensionIndex=gp.dimensionIndex;
lastLevelIndex=gp.levelIndex;
}
 else {
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
}
hasLast=true;
}
 else if (ev.type == ColumnEvent.COLUMN_TOTAL_CHANGE || ev.type == ColumnEvent.GRAND_TOTAL_CHANGE) {
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (ev.type == ColumnEvent.ROW_EDGE_CHANGE && rowIndex == 0) {
rowSpan=hasMeasureHeader(ROW_AXIS_TYPE) ? Math.max(totalMeasureCount,1) : 1;
hasLast=true;
}
 else if (ev.type == ColumnEvent.MEASURE_HEADER_CHANGE) {
rowSpan=1;
colSpan=0;
hasLast=true;
}
currentChangeType=ev.type;
currentEdgePosition=ev.dataPosition;
colSpan++;
currentColIndex++;
if (nextExecutor != null) {
return nextExecutor;
}
}
}
 catch (OLAPException e) {
logger.log(Level.SEVERE,Messages.getString("String_Node_Str"),e);
}
if (hasLast) {
hasLast=false;
switch (currentChangeType) {
case ColumnEvent.ROW_EDGE_CHANGE:
if (rowIndex == 0) {
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getGrandTotal(ROW_AXIS_TYPE),rowSpan,colSpan,currentColIndex - colSpan + 1);
}
break;
case ColumnEvent.MEASURE_HEADER_CHANGE:
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
int mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowGrandTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
break;
}
}
return nextExecutor;
}

Fixed version (ground truth):
public IReportItemExecutor getNextChild(){
  IReportItemExecutor nextExecutor=null;
  try {
    while (walker.hasNext()) {
      ColumnEvent ev=walker.next();
switch (currentChangeType) {
case ColumnEvent.ROW_EDGE_CHANGE:
        if (ev.type != ColumnEvent.ROW_EDGE_CHANGE && isFirstTotalRow) {
          nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getGrandTotal(ROW_AXIS_TYPE),rowSpan,colSpan,currentColIndex - colSpan + 1);
          hasLast=false;
        }
      break;
case ColumnEvent.MEASURE_HEADER_CHANGE:
    nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
  hasLast=false;
break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
int mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowGrandTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
hasLast=false;
break;
}
if (ev.type == ColumnEvent.MEASURE_CHANGE || ev.type == ColumnEvent.COLUMN_EDGE_CHANGE) {
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
if (columnGroups != null && columnGroups.size() > 0) {
EdgeGroup gp=(EdgeGroup)columnGroups.get(columnGroups.size() - 1);
lastDimensionIndex=gp.dimensionIndex;
lastLevelIndex=gp.levelIndex;
}
 else {
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
}
hasLast=true;
}
 else if (ev.type == ColumnEvent.COLUMN_TOTAL_CHANGE || ev.type == ColumnEvent.GRAND_TOTAL_CHANGE) {
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (ev.type == ColumnEvent.ROW_EDGE_CHANGE && isFirstTotalRow) {
rowSpan=totalRowSpan;
hasLast=true;
}
 else if (ev.type == ColumnEvent.MEASURE_HEADER_CHANGE) {
rowSpan=1;
colSpan=0;
hasLast=true;
}
currentChangeType=ev.type;
currentEdgePosition=ev.dataPosition;
colSpan++;
currentColIndex++;
if (nextExecutor != null) {
return nextExecutor;
}
}
}
 catch (OLAPException e) {
logger.log(Level.SEVERE,Messages.getString("String_Node_Str"),e);
}
if (hasLast) {
hasLast=false;
switch (currentChangeType) {
case ColumnEvent.ROW_EDGE_CHANGE:
if (isFirstTotalRow) {
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getGrandTotal(ROW_AXIS_TYPE),rowSpan,colSpan,currentColIndex - colSpan + 1);
}
break;
case ColumnEvent.MEASURE_HEADER_CHANGE:
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
int mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowGrandTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
break;
}
}
return nextExecutor;
}