Program: 76114
Project: 76114
Buggy source:
private void advance(){
  try {
    while (walker.hasNext()) {
      ColumnEvent ev=walker.next();
switch (currentChangeType) {
case ColumnEvent.ROW_EDGE_CHANGE:
        if (rowEdgeStarted) {
          nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,lastDimensionIndex).getLevel(lastLevelIndex).getCell(),rowSpan,colSpan,currentColIndex - colSpan + 1);
          rowEdgeStarted=false;
          hasLast=false;
        }
 else         if (rowSubTotalStarted && ev.type != ColumnEvent.ROW_EDGE_CHANGE) {
          nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,dimensionIndex).getLevel(levelIndex).getAggregationHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
          rowSubTotalStarted=false;
          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,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
hasLast=false;
break;
}
if (isRowEdgeNeedStart(ev)) {
rowEdgeStarted=true;
rowSpan=GroupUtil.computeRowSpan(crosstabItem,rowGroups,ev.dimensionIndex,ev.levelIndex,getRowEdgeCursor(),isLayoutDownThenOver) * factor;
colSpan=0;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (!rowSubTotalStarted && ev.type == ColumnEvent.ROW_EDGE_CHANGE && ev.dimensionIndex == startTotalDimensionIndex && ev.levelIndex == startTotalLevelIndex && rowIndex == 0) {
rowSubTotalStarted=true;
rowSpan=factor;
colSpan=0;
hasLast=true;
}
 else 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.MEASURE_HEADER_CHANGE) {
rowSpan=1;
colSpan=0;
hasLast=true;
}
currentChangeType=ev.type;
currentEdgePosition=ev.dataPosition;
colSpan++;
currentColIndex++;
if (nextExecutor != null) {
return;
}
}
}
 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 (rowEdgeStarted) {
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,lastDimensionIndex).getLevel(lastLevelIndex).getCell(),rowSpan,colSpan,currentColIndex - colSpan + 1);
rowEdgeStarted=false;
}
 else if (rowSubTotalStarted) {
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,dimensionIndex).getLevel(levelIndex).getAggregationHeader(),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,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
break;
}
}
}

Fixed version (ground truth):
private void advance(){
  try {
    while (walker.hasNext()) {
      ColumnEvent ev=walker.next();
switch (currentChangeType) {
case ColumnEvent.ROW_EDGE_CHANGE:
        if (rowEdgeStarted) {
          nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,lastDimensionIndex).getLevel(lastLevelIndex).getCell(),rowSpan,colSpan,currentColIndex - colSpan + 1);
          rowEdgeStarted=false;
          hasLast=false;
        }
 else         if (rowSubTotalStarted && ev.type != ColumnEvent.ROW_EDGE_CHANGE) {
          nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,dimensionIndex).getLevel(levelIndex).getAggregationHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
          rowSubTotalStarted=false;
          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,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
hasLast=false;
break;
}
if (isRowEdgeNeedStart(ev)) {
rowEdgeStarted=true;
rowSpan=GroupUtil.computeRowSpan(crosstabItem,rowGroups,ev.dimensionIndex,ev.levelIndex,getRowEdgeCursor(),isLayoutDownThenOver);
colSpan=0;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (!rowSubTotalStarted && ev.type == ColumnEvent.ROW_EDGE_CHANGE && ev.dimensionIndex == startTotalDimensionIndex && ev.levelIndex == startTotalLevelIndex && isFirstTotalRow) {
rowSubTotalStarted=true;
rowSpan=totalRowSpan;
colSpan=0;
hasLast=true;
}
 else 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.MEASURE_HEADER_CHANGE) {
rowSpan=1;
colSpan=0;
hasLast=true;
}
currentChangeType=ev.type;
currentEdgePosition=ev.dataPosition;
colSpan++;
currentColIndex++;
if (nextExecutor != null) {
return;
}
}
}
 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 (rowEdgeStarted) {
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,lastDimensionIndex).getLevel(lastLevelIndex).getCell(),rowSpan,colSpan,currentColIndex - colSpan + 1);
rowEdgeStarted=false;
}
 else if (rowSubTotalStarted) {
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getDimension(ROW_AXIS_TYPE,dimensionIndex).getLevel(levelIndex).getAggregationHeader(),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,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
break;
}
}
}