Program: 66998
Project: 66998
Buggy source:
public DrilledAggregateResultSet(IAggregationResultSet aggregationRsFromCube,List<IEdgeDrillFilter[]> drillFilters) throws IOException, DataException {
  bufferedStructureArray=new BufferedStructureArray(AggregationResultRow.getCreator(),2000);
  this.dimLevel=aggregationRsFromCube.getAllLevels();
  this.aggregationRsFromCube=aggregationRsFromCube;
  if (aggregationRsFromCube.getAggregationCount() > 0) {
    AggregationDefinition aggr=aggregationRsFromCube.getAggregationDefinition();
    calculator=new DrilledAggregationCalculator(aggr);
  }
  for (int k=0; k < aggregationRsFromCube.length(); k++) {
    aggregationRsFromCube.seek(k);
    IEdgeDrillFilter targetDrill=getTargetDrillOperation(aggregationRsFromCube.getCurrentRow(),drillFilters);
    if (targetDrill == null) {
      bufferedStructureArray.add(aggregationRsFromCube.getCurrentRow());
      continue;
    }
    List<IAggregationResultRow> tempBufferArray=populateResultSet(aggregationRsFromCube,targetDrill);
    List<IEdgeDrillFilter[]> drills=this.getRemainingDrillOperation(targetDrill,drillFilters);
    if (!drills.isEmpty()) {
      tempBufferArray=populateNextResultSet(tempBufferArray,drills);
    }
    if (this.calculator == null) {
      removeDuplictedRow(tempBufferArray);
    }
 else     recalculateAggregation(tempBufferArray);
    sortAggregationRow(tempBufferArray);
    Iterator<IAggregationResultRow> iter=tempBufferArray.iterator();
    while (iter.hasNext())     bufferedStructureArray.add(iter.next());
    k=aggregationRsFromCube.getPosition();
  }
  this.resultObject=(IAggregationResultRow)bufferedStructureArray.get(0);
}

Fixed version (ground truth):
public DrilledAggregateResultSet(IAggregationResultSet aggregationRsFromCube,List<IEdgeDrillFilter[]> drillFilters) throws IOException, DataException {
  bufferedStructureArray=new BufferedStructureArray(AggregationResultRow.getCreator(),2000);
  this.dimLevel=aggregationRsFromCube.getAllLevels();
  this.aggregationRsFromCube=aggregationRsFromCube;
  if (aggregationRsFromCube.getAggregationCount() > 0) {
    AggregationDefinition aggr=aggregationRsFromCube.getAggregationDefinition();
    calculator=new DrilledAggregationCalculator(aggr);
  }
  drillFilterTargetLevels=new HashMap<IEdgeDrillFilter,List<DimLevel>>();
  for (int i=0; i < drillFilters.size(); i++) {
    IEdgeDrillFilter[] filters=drillFilters.get(i);
    for (int t=0; t < filters.length; t++) {
      drillFilterTargetLevels.put(filters[t],CubeQueryDefinitionUtil.getDrilledTargetLevels(filters[t]));
    }
  }
  for (int k=0; k < aggregationRsFromCube.length(); k++) {
    aggregationRsFromCube.seek(k);
    IEdgeDrillFilter targetDrill=getTargetDrillOperation(aggregationRsFromCube.getCurrentRow(),drillFilters);
    if (targetDrill == null) {
      bufferedStructureArray.add(aggregationRsFromCube.getCurrentRow());
      continue;
    }
    List<IAggregationResultRow> tempBufferArray=populateResultSet(aggregationRsFromCube,targetDrill);
    List<IEdgeDrillFilter[]> drills=this.getRemainingDrillOperation(targetDrill,drillFilters);
    if (!drills.isEmpty()) {
      tempBufferArray=populateNextResultSet(tempBufferArray,drills);
    }
    if (this.calculator == null) {
      removeDuplictedRow(tempBufferArray);
    }
 else     recalculateAggregation(tempBufferArray);
    sortAggregationRow(tempBufferArray);
    Iterator<IAggregationResultRow> iter=tempBufferArray.iterator();
    while (iter.hasNext())     bufferedStructureArray.add(iter.next());
    k=aggregationRsFromCube.getPosition();
  }
  this.resultObject=(IAggregationResultRow)bufferedStructureArray.get(0);
}