Program: 66372
Project: 66372
Buggy source:
/** 
 * @param stopSign
 * @throws IOException
 * @throws BirtException
 */
private void populateSortedFactRows(StopSign stopSign) throws IOException, DataException {
  prepareSortedStacks();
  int measureCount=dataSet4Aggregation.getMetaInfo().getMeasureInfos().length;
  int factRowCount=0;
  try {
    while (dataSet4Aggregation.next() && !stopSign.isStopped()) {
      for (int i=0; i < allSortedFactRows.size(); i++) {
        DiskSortedStackWrapper diskSortedStackWrapper=((DiskSortedStackWrapper)allSortedFactRows.get(i));
        int[] levelIndex=diskSortedStackWrapper.levelIndex;
        Row4Aggregation aggregationRow=new Row4Aggregation();
        aggregationRow.setDimPos(dataSet4Aggregation.getDimensionPosition());
        aggregationRow.setLevelMembers(getLevelMembers(levelIndex));
        if (aggregationRow.getLevelMembers() == null) {
          continue;
        }
        aggregationRow.setMeasures(new Object[measureCount]);
        for (int j=0; j < measureCount; j++) {
          aggregationRow.getMeasures()[j]=dataSet4Aggregation.getMeasureValue(j);
        }
        aggregationRow.setParameterValues(getParameterValues());
        diskSortedStackWrapper.diskSortedStack.push(aggregationRow);
      }
      factRowCount++;
      if (maxDataObjectRows > 0 && factRowCount > maxDataObjectRows)       throw new DataException(ResourceConstants.EXCEED_MAX_DATA_OBJECT_ROWS);
    }
  }
 catch (  BirtException e) {
    throw DataException.wrap(e);
  }
}

Fixed version (ground truth):
/** 
 * @param stopSign
 * @throws IOException
 * @throws BirtException
 */
private void populateSortedFactRows(StopSign stopSign) throws IOException, DataException {
  prepareSortedStacks();
  int measureCount=dataSet4Aggregation.getMetaInfo().getMeasureInfos().length;
  int factRowCount=0;
  if (this.aggregationRow == null) {
    this.aggregationRow=new Row4Aggregation[allSortedFactRows.size()];
  }
  DiskSortedStackWrapper[] diskSortedStackWrapper=new DiskSortedStackWrapper[allSortedFactRows.size()];
  for (int i=0; i < allSortedFactRows.size(); i++) {
    diskSortedStackWrapper[i]=((DiskSortedStackWrapper)allSortedFactRows.get(i));
  }
  try {
    while (dataSet4Aggregation.next() && !stopSign.isStopped()) {
      for (int i=0; i < allSortedFactRows.size(); i++) {
        int[] levelIndex=diskSortedStackWrapper[i].levelIndex;
        if (!dataSet4Aggregation.isDuplicatedRow()) {
          Member[] members=getLevelMembers(levelIndex);
          if (aggregationRow[i] != null) {
            Row4Aggregation popRow=this.mergeRow4Aggregations[i].push(aggregationRow[i]);
            if (popRow != null)             diskSortedStackWrapper[i].diskSortedStack.push(popRow);
          }
          aggregationRow[i]=new Row4Aggregation();
          aggregationRow[i].setDimPos(dataSet4Aggregation.getDimensionPosition());
          aggregationRow[i].setLevelMembers(members);
          if (aggregationRow[i].getLevelMembers() == null) {
            continue;
          }
          aggregationRow[i].setMeasures(new Object[measureCount]);
          for (int j=0; j < measureCount; j++) {
            aggregationRow[i].getMeasures()[j]=dataSet4Aggregation.getMeasureValue(j);
          }
          aggregationRow[i].setParameterValues(getParameterValues());
        }
 else {
          Object[] measures=new Object[measureCount];
          for (int j=0; j < measureCount; j++) {
            measures[j]=dataSet4Aggregation.getMeasureValue(j);
          }
          aggregationRow[i].addMeasure(measures);
        }
      }
      factRowCount++;
      if (maxDataObjectRows > 0 && factRowCount > maxDataObjectRows)       throw new DataException(ResourceConstants.EXCEED_MAX_DATA_OBJECT_ROWS);
    }
    for (int i=0; i < allSortedFactRows.size(); i++) {
      if (aggregationRow[i] != null) {
        Row4Aggregation popRow=this.mergeRow4Aggregations[i].push(aggregationRow[i]);
        if (popRow != null)         diskSortedStackWrapper[i].diskSortedStack.push(popRow);
      }
      List<Row4Aggregation> remainRows=this.mergeRow4Aggregations[i].getAll();
      for (int j=0; j < remainRows.size(); j++) {
        diskSortedStackWrapper[i].diskSortedStack.push(remainRows.get(j));
      }
      this.mergeRow4Aggregations[i]=null;
    }
  }
 catch (  BirtException e) {
    throw DataException.wrap(e);
  }
}