Program: 70183
Project: 70183
Buggy source:
private List buildColumnArea(){
  List retValue=new ArrayList();
  CrosstabReportItemHandle handle=getCrosstabReportItemHandle();
  int count=handle.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE);
  int measureCount=handle.getMeasureCount();
  int rowNumber=measureCount == 0 ? 1 : 2;
  if (isVertical() || isHideHeader()) {
    rowNumber=1;
  }
  List measureHandleList=getMeasreViewHandleList();
  int columnNumber=0;
  if (count != 0) {
    columnNumber=addMesureHeader(retValue,0,ICrosstabConstants.COLUMN_AXIS_TYPE,measureHandleList);
  }
  if (columnNumber == 0) {
    columnNumber=1;
  }
  for (int i=count - 1; i >= 0; i--) {
    DimensionViewHandle dimensionHandle=handle.getDimension(ICrosstabConstants.COLUMN_AXIS_TYPE,i);
    int levelCount=dimensionHandle.getLevelCount();
    for (int j=levelCount - 1; j >= 0; j--) {
      LevelViewHandle levelHandle=dimensionHandle.getLevel(j);
      CrosstabCellHandle cellHandle=levelHandle.getCell();
      String type=j == 0 ? ICrosstabCellAdapterFactory.CELL_FIRST_LEVEL_HANDLE : ICrosstabCellAdapterFactory.CELL_LEVEL_HANDLE;
      CrosstabCellAdapter cellAdapter=factory.createCrosstabCellAdapter(type,cellHandle,rowNumber,1,1,columnNumber,false);
      retValue.add(cellAdapter);
      map.put(levelHandle,Integer.valueOf(columnNumber));
      LevelViewHandle preLevelHandle=getPreviousLevelViewHandle(dimensionHandle,levelHandle);
      if (preLevelHandle != null && preLevelHandle.getAggregationHeader() != null) {
        List list=preLevelHandle.getAggregationMeasures();
        if (list.size() != 0) {
          int preMeasureCount=list.size();
          CrosstabCellHandle preCellHandle=preLevelHandle.getAggregationHeader();
          CrosstabCellAdapter preCellAdapter=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_SUB_TOTAL,preCellHandle,rowNumber,rowNumber - (isVertical() || isHideHeader() ? 0 : 1),columnNumber + 1,isVertical() ? 1 : preMeasureCount,false);
          retValue.add(preCellAdapter);
          int addCount=addMesureHeader(retValue,columnNumber,ICrosstabConstants.COLUMN_AXIS_TYPE,list);
          columnNumber=columnNumber + (addCount == 0 ? 1 : addCount);
        }
      }
      if (j != 0 || i != 0) {
        rowNumber=rowNumber + 1;
      }
    }
  }
  CrosstabCellHandle grandCell=handle.getGrandTotal(ICrosstabConstants.COLUMN_AXIS_TYPE);
  if (grandCell != null && !retValue.isEmpty()) {
    List list=handle.getAggregationMeasures(ICrosstabConstants.COLUMN_AXIS_TYPE);
    int size=list.size();
    if (size > 0) {
      CrosstabCellAdapter grandCellAdapter=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_GRAND_TOTAL,grandCell,rowNumber,rowNumber - (isVertical() || isHideHeader() ? 0 : 1),columnNumber + 1,isVertical() ? 1 : size,false);
      retValue.add(grandCellAdapter);
      int addCount=addMesureHeader(retValue,columnNumber,ICrosstabConstants.COLUMN_AXIS_TYPE,list);
      int beforeColumnNumber=columnNumber;
      columnNumber=columnNumber + (addCount == 0 ? 1 : addCount);
      if (isGrandBefore(ICrosstabConstants.COLUMN_AXIS_TYPE)) {
        adjustGrandColumn=columnNumber - beforeColumnNumber;
      }
    }
  }
  if (retValue.isEmpty()) {
    CrosstabCellAdapter columnVirtual=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_COLUMN_VIRTUAL,null,1,-1,1,-1,false);
    retValue.add(columnVirtual);
    columnNumber=1;
    rowNumber=1;
  }
  map.put(COLUMNAREA_COLUMN,Integer.valueOf(columnNumber));
  map.put(COLUMNAREA_ROW,Integer.valueOf(rowNumber));
  covertRowNumber(rowNumber,retValue);
  return retValue;
}

Fixed version (ground truth):
private List buildColumnArea(){
  List retValue=new ArrayList();
  CrosstabReportItemHandle handle=getCrosstabReportItemHandle();
  int count=handle.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE);
  int measureCount=handle.getMeasureCount();
  int rowNumber=measureCount == 0 ? 1 : 2;
  if (isVertical() || isHideHeader()) {
    rowNumber=1;
  }
  List measureHandleList=getMeasreViewHandleList();
  int columnNumber=0;
  if (count != 0) {
    LevelViewHandle lastHandle=findLastLevelViewHandle(ICrosstabConstants.COLUMN_AXIS_TYPE);
    if (lastHandle == null) {
      throw new RuntimeException("String_Node_Str");
    }
    columnNumber=addMesureHeader(retValue,0,ICrosstabConstants.COLUMN_AXIS_TYPE,measureHandleList,lastHandle);
  }
  if (columnNumber == 0) {
    columnNumber=1;
  }
  for (int i=count - 1; i >= 0; i--) {
    DimensionViewHandle dimensionHandle=handle.getDimension(ICrosstabConstants.COLUMN_AXIS_TYPE,i);
    int levelCount=dimensionHandle.getLevelCount();
    for (int j=levelCount - 1; j >= 0; j--) {
      LevelViewHandle levelHandle=dimensionHandle.getLevel(j);
      CrosstabCellHandle cellHandle=levelHandle.getCell();
      String type=j == 0 ? ICrosstabCellAdapterFactory.CELL_FIRST_LEVEL_HANDLE : ICrosstabCellAdapterFactory.CELL_LEVEL_HANDLE;
      CrosstabCellAdapter cellAdapter=factory.createCrosstabCellAdapter(type,cellHandle,rowNumber,1,1,columnNumber,false);
      retValue.add(cellAdapter);
      map.put(levelHandle,Integer.valueOf(columnNumber));
      LevelViewHandle preLevelHandle=getPreviousLevelViewHandle(dimensionHandle,levelHandle);
      if (preLevelHandle != null && preLevelHandle.getAggregationHeader() != null) {
        List list=preLevelHandle.getAggregationMeasures();
        if (list.size() != 0) {
          int preMeasureCount=list.size();
          CrosstabCellHandle preCellHandle=preLevelHandle.getAggregationHeader();
          CrosstabCellAdapter preCellAdapter=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_SUB_TOTAL,preCellHandle,rowNumber,rowNumber - (isVertical() || isHideHeader() ? 0 : 1),columnNumber + 1,isVertical() ? 1 : preMeasureCount,false);
          retValue.add(preCellAdapter);
          int addCount=addMesureHeader(retValue,columnNumber,ICrosstabConstants.COLUMN_AXIS_TYPE,list,preLevelHandle);
          columnNumber=columnNumber + (addCount == 0 ? 1 : addCount);
        }
      }
      if (j != 0 || i != 0) {
        rowNumber=rowNumber + 1;
      }
    }
  }
  CrosstabCellHandle grandCell=handle.getGrandTotal(ICrosstabConstants.COLUMN_AXIS_TYPE);
  if (grandCell != null && !retValue.isEmpty()) {
    List list=handle.getAggregationMeasures(ICrosstabConstants.COLUMN_AXIS_TYPE);
    int size=list.size();
    if (size > 0) {
      CrosstabCellAdapter grandCellAdapter=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_GRAND_TOTAL,grandCell,rowNumber,rowNumber - (isVertical() || isHideHeader() ? 0 : 1),columnNumber + 1,isVertical() ? 1 : size,false);
      retValue.add(grandCellAdapter);
      int addCount=addMesureHeader(retValue,columnNumber,ICrosstabConstants.COLUMN_AXIS_TYPE,list,null);
      int beforeColumnNumber=columnNumber;
      columnNumber=columnNumber + (addCount == 0 ? 1 : addCount);
      if (isGrandBefore(ICrosstabConstants.COLUMN_AXIS_TYPE)) {
        adjustGrandColumn=columnNumber - beforeColumnNumber;
      }
    }
  }
  if (retValue.isEmpty()) {
    CrosstabCellAdapter columnVirtual=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_COLUMN_VIRTUAL,null,1,-1,1,-1,false);
    retValue.add(columnVirtual);
    columnNumber=1;
    rowNumber=1;
  }
  map.put(COLUMNAREA_COLUMN,Integer.valueOf(columnNumber));
  map.put(COLUMNAREA_ROW,Integer.valueOf(rowNumber));
  covertRowNumber(rowNumber,retValue);
  return retValue;
}