Program: 75492
Project: 75492
Buggy source:
/** 
 * @param aggregations
 * @param resultSet
 * @param levelFilterList
 * @throws IOException 
 * @throws DataException 
 */
private void applyTopBottomFilters(AggregationDefinition[] aggregations,IAggregationResultSet[] resultSet,List levelFilterList) throws DataException, IOException {
  for (int i=0; i < aggregations.length; i++) {
    if (aggregations[i].getAggregationFunctions() == null)     continue;
    Map levelFilterMap=new HashMap();
    for (Iterator j=topbottomFilters.iterator(); j.hasNext(); ) {
      TopBottomFilter filter=(TopBottomFilter)j.next();
      if (filter.getFilterHelper().isAggregationFilter()) {
        if (isEqualLevels(aggregations[i].getLevels(),filter.getAggrLevels())) {
          IDiskArray levelKeyList=populateLevelKeyList(aggregations[i],resultSet[i],filter);
          IDiskArray selectedLevelKeys=null;
          if (levelFilterMap.containsKey(filter.getTargetLevel())) {
            selectedLevelKeys=(IDiskArray)levelFilterMap.get(filter.getTargetLevel());
            selectedLevelKeys=interKeys(selectedLevelKeys,levelKeyList);
          }
 else {
            selectedLevelKeys=levelKeyList;
          }
          levelFilterMap.put(filter.getTargetLevel(),selectedLevelKeys);
        }
      }
    }
    for (Iterator j=levelFilterMap.keySet().iterator(); j.hasNext(); ) {
      DimLevel target=(DimLevel)j.next();
      List selectedKeyList=(List)levelFilterMap.get(target);
      if (selectedKeyList.size() == 0)       continue;
      Object[][] keys=new Object[selectedKeyList.size()][];
      for (int k=0; k < keys.length; k++) {
        keys[k]=((MultiKey)selectedKeyList.get(k)).levelKey;
      }
      ISelection selection=SelectionFactory.createMutiKeySelection(keys);
      LevelFilter filter=new LevelFilter(target,new ISelection[]{selection});
      levelFilterList.add(filter);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param aggregations
 * @param resultSet
 * @param levelFilterList
 * @throws IOException 
 * @throws DataException 
 */
private void applyTopBottomFilters(AggregationDefinition[] aggregations,IAggregationResultSet[] resultSet,List levelFilterList) throws DataException, IOException {
  for (int i=0; i < aggregations.length; i++) {
    if (aggregations[i].getAggregationFunctions() == null)     continue;
    Map levelFilterMap=new HashMap();
    for (Iterator j=topbottomFilters.iterator(); j.hasNext(); ) {
      TopBottomFilter filter=(TopBottomFilter)j.next();
      if (filter.getFilterHelper().isAggregationFilter()) {
        if (isEqualLevels(aggregations[i].getLevels(),filter.getAggrLevels())) {
          IDiskArray levelKeyList=populateLevelKeyList(aggregations[i],resultSet[i],filter);
          IDiskArray selectedLevelKeys=null;
          if (levelFilterMap.containsKey(filter.getTargetLevel())) {
            selectedLevelKeys=(IDiskArray)levelFilterMap.get(filter.getTargetLevel());
            selectedLevelKeys=interKeys(selectedLevelKeys,levelKeyList);
          }
 else {
            selectedLevelKeys=levelKeyList;
          }
          levelFilterMap.put(filter.getTargetLevel(),selectedLevelKeys);
        }
      }
    }
    for (Iterator j=levelFilterMap.keySet().iterator(); j.hasNext(); ) {
      DimLevel target=(DimLevel)j.next();
      IDiskArray selectedKeyArray=(IDiskArray)levelFilterMap.get(target);
      if (selectedKeyArray.size() == 0)       continue;
      Object[][] keys=new Object[selectedKeyArray.size()][];
      for (int k=0; k < keys.length; k++) {
        keys[k]=((MultiKey)selectedKeyArray.get(k)).levelKey;
      }
      ISelection selection=SelectionFactory.createMutiKeySelection(keys);
      LevelFilter filter=new LevelFilter(target,new ISelection[]{selection});
      levelFilterList.add(filter);
    }
  }
}