Program: 72914
Project: 72914
Buggy source:
protected void advance(){
  int mx;
  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);
          ((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
          ((CrosstabCellExecutor)nextExecutor).setForceEmpty(isForceEmpty());
          rowEdgeStarted=false;
          hasLast=false;
        }
      break;
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 (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 (isMeasureDetailNeedStart(ev)) {
measureDetailStarted=true;
if (ev.measureIndex == -1) {
rowSpan=1;
}
 else {
rowSpan=GroupUtil.computeAggregationCellRowOverSpan(crosstabItem,rowGroups,getMeasureCell(ev.measureIndex).getSpanOverOnRow(),getRowEdgeCursor());
}
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureSubTotalNeedStart(ev)) {
measureSubTotalStarted=true;
if (ev.measureIndex == -1) {
rowSpan=1;
}
 else {
int dimCount=crosstabItem.getDimensionCount(ROW_AXIS_TYPE);
DimensionViewHandle rdv=crosstabItem.getDimension(ROW_AXIS_TYPE,dimCount - 1);
rowSpan=GroupUtil.computeAggregationCellRowOverSpan(crosstabItem,rowGroups,getAggregationCell(dimCount - 1,rdv.getLevelCount() - 1,ev.dimensionIndex,ev.levelIndex,ev.measureIndex).getSpanOverOnRow(),getRowEdgeCursor());
}
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureGrandTotalNeedStart(ev)) {
measureGrandTotalStarted=true;
if (ev.measureIndex == -1) {
rowSpan=1;
}
 else {
int dimCount=crosstabItem.getDimensionCount(ROW_AXIS_TYPE);
DimensionViewHandle rdv=crosstabItem.getDimension(ROW_AXIS_TYPE,dimCount - 1);
rowSpan=GroupUtil.computeAggregationCellRowOverSpan(crosstabItem,rowGroups,getAggregationCell(dimCount - 1,rdv.getLevelCount() - 1,ev.dimensionIndex,ev.levelIndex,ev.measureIndex).getSpanOverOnRow(),getRowEdgeCursor());
}
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);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
((CrosstabCellExecutor)nextExecutor).setForceEmpty(isForceEmpty());
rowEdgeStarted=false;
}
break;
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;
}
}
}

Fixed version (ground truth):
protected void advance(){
  int mx;
  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);
          ((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
          ((CrosstabCellExecutor)nextExecutor).setForceEmpty(isForceEmpty());
          rowEdgeStarted=false;
          hasLast=false;
        }
      break;
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 (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 (isMeasureDetailNeedStart(ev)) {
measureDetailStarted=true;
if (ev.measureIndex == -1 && totalMeasureCount != 1) {
rowSpan=1;
}
 else {
mx=ev.measureIndex;
if (mx == -1) {
mx=0;
}
rowSpan=GroupUtil.computeAggregationCellRowOverSpan(crosstabItem,rowGroups,getMeasureCell(mx).getSpanOverOnRow(),getRowEdgeCursor());
}
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureSubTotalNeedStart(ev)) {
measureSubTotalStarted=true;
if (ev.measureIndex == -1 && totalMeasureCount != 1) {
rowSpan=1;
}
 else {
mx=ev.measureIndex;
if (mx == -1) {
mx=0;
}
int dimCount=crosstabItem.getDimensionCount(ROW_AXIS_TYPE);
DimensionViewHandle rdv=crosstabItem.getDimension(ROW_AXIS_TYPE,dimCount - 1);
rowSpan=GroupUtil.computeAggregationCellRowOverSpan(crosstabItem,rowGroups,getAggregationCell(dimCount - 1,rdv.getLevelCount() - 1,ev.dimensionIndex,ev.levelIndex,mx).getSpanOverOnRow(),getRowEdgeCursor());
}
colSpan=0;
lastMeasureIndex=ev.measureIndex;
lastDimensionIndex=ev.dimensionIndex;
lastLevelIndex=ev.levelIndex;
hasLast=true;
}
 else if (isMeasureGrandTotalNeedStart(ev)) {
measureGrandTotalStarted=true;
if (ev.measureIndex == -1 && totalMeasureCount != 1) {
rowSpan=1;
}
 else {
mx=ev.measureIndex;
if (mx == -1) {
mx=0;
}
int dimCount=crosstabItem.getDimensionCount(ROW_AXIS_TYPE);
DimensionViewHandle rdv=crosstabItem.getDimension(ROW_AXIS_TYPE,dimCount - 1);
rowSpan=GroupUtil.computeAggregationCellRowOverSpan(crosstabItem,rowGroups,getAggregationCell(dimCount - 1,rdv.getLevelCount() - 1,ev.dimensionIndex,ev.levelIndex,mx).getSpanOverOnRow(),getRowEdgeCursor());
}
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);
((CrosstabCellExecutor)nextExecutor).setPosition(currentEdgePosition);
((CrosstabCellExecutor)nextExecutor).setForceEmpty(isForceEmpty());
rowEdgeStarted=false;
}
break;
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;
}
}
}