Program: 73342
Project: 73342
Buggy source:
protected void advance(){
  int mx;
  try {
    while (walker.hasNext()) {
      ColumnEvent ev=walker.next();
switch (currentChangeType) {
case ColumnEvent.MEASURE_HEADER_CHANGE:
        nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
      ((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
    hasLast=false;
  break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
if (measureDetailStarted && isMeetMeasureDetailEnd(ev,totalMeasureCount > 0 ? crosstabItem.getMeasure(mx).getCell() : null)) {
nextExecutor=new CrosstabCellExecutor(this,totalMeasureCount > 0 ? crosstabItem.getMeasure(mx).getCell() : null,rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureDetailStarted=false;
hasLast=false;
}
 else if (measureSubTotalStarted) {
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureSubTotalStarted=false;
hasLast=false;
}
 else if (measureGrandTotalStarted) {
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureGrandTotalStarted=false;
hasLast=false;
}
break;
}
if (isMeasureDetailNeedStart(ev)) {
measureDetailStarted=true;
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureSubTotalNeedStart(ev)) {
measureSubTotalStarted=true;
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureGrandTotalNeedStart(ev)) {
measureGrandTotalStarted=true;
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;
}
currentEdgePosition=ev.dataPosition;
currentChangeType=ev.type;
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.MEASURE_HEADER_CHANGE:
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
break;
}
if (measureDetailStarted) {
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,totalMeasureCount > 0 ? crosstabItem.getMeasure(mx).getCell() : null,rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureDetailStarted=false;
}
 else if (measureSubTotalStarted) {
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureSubTotalStarted=false;
}
 else if (measureGrandTotalStarted) {
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureGrandTotalStarted=false;
}
}
}

Fixed version (ground truth):
protected void advance(){
  int mx;
  try {
    while (walker.hasNext()) {
      ColumnEvent ev=walker.next();
switch (currentChangeType) {
case ColumnEvent.MEASURE_HEADER_CHANGE:
        nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
      ((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
    hasLast=false;
  break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
if (measureDetailStarted && isMeetMeasureDetailEnd(ev,totalMeasureCount > 0 ? getMeasureCell(mx) : null)) {
nextExecutor=new CrosstabCellExecutor(this,totalMeasureCount > 0 ? getMeasureCell(mx) : null,rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureDetailStarted=false;
hasLast=false;
}
 else if (measureSubTotalStarted) {
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureSubTotalStarted=false;
hasLast=false;
}
 else if (measureGrandTotalStarted) {
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureGrandTotalStarted=false;
hasLast=false;
}
break;
}
if (isMeasureDetailNeedStart(ev)) {
measureDetailStarted=true;
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureSubTotalNeedStart(ev)) {
measureSubTotalStarted=true;
rowSpan=1;
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureGrandTotalNeedStart(ev)) {
measureGrandTotalStarted=true;
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;
}
currentEdgePosition=ev.dataPosition;
currentChangeType=ev.type;
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.MEASURE_HEADER_CHANGE:
nextExecutor=new CrosstabCellExecutor(this,crosstabItem.getMeasure(rowIndex).getHeader(),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
break;
case ColumnEvent.MEASURE_CHANGE:
case ColumnEvent.COLUMN_EDGE_CHANGE:
case ColumnEvent.COLUMN_TOTAL_CHANGE:
case ColumnEvent.GRAND_TOTAL_CHANGE:
break;
}
if (measureDetailStarted) {
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,totalMeasureCount > 0 ? getMeasureCell(mx) : null,rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureDetailStarted=false;
}
 else if (measureSubTotalStarted) {
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureSubTotalStarted=false;
}
 else if (measureGrandTotalStarted) {
mx=lastMeasureIndex < 0 ? rowIndex : lastMeasureIndex;
nextExecutor=new CrosstabCellExecutor(this,getRowSubTotalCell(lastDimensionIndex,lastLevelIndex,mx),rowSpan,colSpan,currentColIndex - colSpan + 1);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
measureGrandTotalStarted=false;
}
}
}