Program: 75496
Project: 75496
Buggy source:
/** 
 * @param aggregations
 * @param resultSet
 * @param j
 * @param filter
 * @param levelFilters
 * @throws IOException
 * @throws DataException
 */
private void applyAggrFilter(AggregationDefinition[] aggregations,IAggregationResultSet[] resultSet,int j,AggrFilter filter,List levelFilters) throws IOException, DataException {
  List selKeyValueList=new ArrayList();
  AggregationFunctionDefinition[] aggrFuncs=aggregations[j].getAggregationFunctions();
  DimLevel[] aggrLevels=filter.getAggrLevels();
  String[] fields=getAllFieldNames(aggrLevels,resultSet[j]);
  String[] aggrNames=new String[aggrFuncs.length];
  for (int k=0; k < aggrFuncs.length; k++) {
    aggrNames[k]=aggrFuncs[k].getName();
  }
  for (int k=0; k < resultSet[j].length(); k++) {
    resultSet[j].seek(k);
    int fieldIndex=0;
    Object[] fieldValues=new Object[fields.length];
    Object[] aggrValues=new Object[aggrFuncs.length];
    for (int m=0; m < aggrLevels.length; m++) {
      int levelIndex=resultSet[j].getLevelIndex(aggrLevels[m]);
      if (levelIndex < 0 || levelIndex >= resultSet[j].getLevelCount())       continue;
      fieldValues[fieldIndex++]=resultSet[j].getLevelKeyValue(levelIndex)[0];
    }
    for (int m=0; m < aggrFuncs.length; m++) {
      int aggrIndex=resultSet[j].getAggregationIndex(aggrNames[m]);
      aggrValues[m]=resultSet[j].getAggregationValue(aggrIndex);
    }
    RowForFilter row=new RowForFilter(fields,aggrNames);
    row.setFieldValues(fieldValues);
    row.setAggrValues(aggrValues);
    boolean isSelect=filter.getFilterHelper().evaluateFilter(row);
    if (isSelect) {
      int levelIndex=resultSet[j].getLevelIndex(filter.getTargetLevel());
      Object[] levelKeyValue=resultSet[j].getLevelKeyValue(levelIndex);
      if (levelKeyValue != null && levelKeyValue[0] != null)       selKeyValueList.add(levelKeyValue);
    }
  }
  if (selKeyValueList.isEmpty()) {
    noRecal[j]=true;
  }
 else {
    Object[][] keyValues=new Object[selKeyValueList.size()][];
    for (int i=0; i < selKeyValueList.size(); i++) {
      keyValues[i]=(Object[])selKeyValueList.get(i);
    }
    ISelection selection=SelectionFactory.createMutiKeySelection(keyValues);
    LevelFilter levelFilter=new LevelFilter(filter.getTargetLevel(),new ISelection[]{selection});
    levelFilters.add(levelFilter);
  }
}

Fixed version (ground truth):
/** 
 * @param aggregations
 * @param resultSet
 * @param j
 * @param filter
 * @param levelFilters
 * @throws IOException
 * @throws DataException
 */
private void applyAggrFilter(AggregationDefinition[] aggregations,IAggregationResultSet[] resultSet,int j,AggrFilter filter,List levelFilters) throws IOException, DataException {
  List selKeyValueList=new ArrayList();
  AggregationFunctionDefinition[] aggrFuncs=aggregations[j].getAggregationFunctions();
  DimLevel[] aggrLevels=filter.getAggrLevels();
  String[] fields=getAllFieldNames(aggrLevels,resultSet[j]);
  String[] aggrNames=new String[aggrFuncs.length];
  for (int k=0; k < aggrFuncs.length; k++) {
    aggrNames[k]=aggrFuncs[k].getName();
  }
  for (int k=0; k < resultSet[j].length(); k++) {
    resultSet[j].seek(k);
    int fieldIndex=0;
    Object[] fieldValues=new Object[fields.length];
    Object[] aggrValues=new Object[aggrFuncs.length];
    for (int m=0; m < aggrLevels.length; m++) {
      int levelIndex=resultSet[j].getLevelIndex(aggrLevels[m]);
      if (levelIndex < 0 || levelIndex >= resultSet[j].getLevelCount())       continue;
      fieldValues[fieldIndex++]=resultSet[j].getLevelKeyValue(levelIndex)[0];
    }
    for (int m=0; m < aggrFuncs.length; m++) {
      int aggrIndex=resultSet[j].getAggregationIndex(aggrNames[m]);
      aggrValues[m]=resultSet[j].getAggregationValue(aggrIndex);
    }
    RowForFilter row=new RowForFilter(fields,aggrNames);
    row.setFieldValues(fieldValues);
    row.setAggrValues(aggrValues);
    boolean isSelect=filter.getFilterHelper().evaluateFilter(row);
    if (isSelect) {
      int levelIndex=resultSet[j].getLevelIndex(filter.getTargetLevel());
      Object[] levelKeyValue=resultSet[j].getLevelKeyValue(levelIndex);
      if (levelKeyValue != null && levelKeyValue[0] != null)       selKeyValueList.add(levelKeyValue);
    }
  }
  if (selKeyValueList.isEmpty()) {
    skip[j]=true;
  }
 else {
    Object[][] keyValues=new Object[selKeyValueList.size()][];
    for (int i=0; i < selKeyValueList.size(); i++) {
      keyValues[i]=(Object[])selKeyValueList.get(i);
    }
    ISelection selection=SelectionFactory.createMutiKeySelection(keyValues);
    LevelFilter levelFilter=new LevelFilter(filter.getTargetLevel(),new ISelection[]{selection});
    levelFilters.add(levelFilter);
  }
}