Program: 70413
Project: 70413
Buggy source:
/** 
 * Populate the dimension.
 * @param cubeMaterializer
 * @param dim
 * @param stopSign
 * @return
 * @throws IOException
 * @throws BirtException
 * @throws DataException
 */
private IDimension populateDimension(CubeMaterializer cubeMaterializer,DimensionHandle dim,TabularCubeHandle cubeHandle,Map appContext,Map<ReportElementHandle,IQueryDefinition> queryMap,Map<ReportElementHandle,List<ColumnMeta>> metaMap) throws IOException, BirtException, DataException {
  List hiers=dim.getContents(DimensionHandle.HIERARCHIES_PROP);
  List iHiers=new ArrayList();
  for (int j=0; j < hiers.size(); j++) {
    TabularHierarchyHandle hierhandle=(TabularHierarchyHandle)hiers.get(0);
    List levels=hierhandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
    ILevelDefn[] levelInHier=null;
    if (hierhandle.getLevelCount() == 1)     levelInHier=new ILevelDefn[1];
 else     levelInHier=new ILevelDefn[hierhandle.getLevelCount() + 1];
    String[] leafLevelKeyColumn=new String[levels.size()];
    for (int k=0; k < levels.size(); k++) {
      TabularLevelHandle level=(TabularLevelHandle)levels.get(k);
      List levelKeys=new ArrayList();
      Iterator it=level.attributesIterator();
      while (it.hasNext()) {
        LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
        levelKeys.add(OlapExpressionUtil.getAttributeColumnName(level.getName(),levelAttr.getName()));
      }
      if (DesignChoiceConstants.LEVEL_TYPE_DYNAMIC.equals(level.getLevelType()) && level.getDisplayColumnName() != null) {
        levelKeys.add(OlapExpressionUtil.getDisplayColumnName(level.getName()));
      }
      leafLevelKeyColumn[k]=level.getName();
      levelInHier[k]=CubeElementFactory.createLevelDefinition(level.getName(),new String[]{level.getName()},this.toStringArray(levelKeys));
    }
    createLeafLevel(levels,levelInHier,leafLevelKeyColumn);
    iHiers.add(cubeMaterializer.createHierarchy(dim.getName(),hierhandle.getName(),new DataSetIterator(this,queryMap.get(hierhandle),metaMap.get(hierhandle),appContext),levelInHier,stopSign));
  }
  return cubeMaterializer.createDimension(dim.getName(),(IHierarchy)iHiers.get(0));
}

Fixed version (ground truth):
/** 
 * Populate the dimension.
 * @param cubeMaterializer
 * @param dim
 * @param stopSign
 * @return
 * @throws IOException
 * @throws BirtException
 * @throws DataException
 */
private IDimension populateDimension(CubeMaterializer cubeMaterializer,DimensionHandle dim,TabularCubeHandle cubeHandle,Map appContext,Map<ReportElementHandle,IQueryDefinition> queryMap,Map<ReportElementHandle,List<ColumnMeta>> metaMap) throws IOException, BirtException, DataException {
  List hiers=dim.getContents(DimensionHandle.HIERARCHIES_PROP);
  List iHiers=new ArrayList();
  for (int j=0; j < hiers.size(); j++) {
    TabularHierarchyHandle hierhandle=(TabularHierarchyHandle)hiers.get(0);
    List levels=hierhandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
    ILevelDefn[] levelInHier=null;
    if (hierhandle.getLevelCount() == 1)     levelInHier=new ILevelDefn[1];
 else     levelInHier=new ILevelDefn[hierhandle.getLevelCount() + 1];
    String[] leafLevelKeyColumn=new String[levels.size()];
    for (int k=0; k < levels.size(); k++) {
      TabularLevelHandle level=(TabularLevelHandle)levels.get(k);
      List levelKeys=new ArrayList();
      Iterator it=level.attributesIterator();
      while (it.hasNext()) {
        LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
        levelKeys.add(OlapExpressionUtil.getAttributeColumnName(level.getName(),levelAttr.getName()));
      }
      if (DesignChoiceConstants.LEVEL_TYPE_DYNAMIC.equals(level.getLevelType()) && level.getDisplayColumnName() != null) {
        levelKeys.add(OlapExpressionUtil.getDisplayColumnName(level.getName()));
      }
      leafLevelKeyColumn[k]=level.getName();
      levelInHier[k]=CubeElementFactory.createLevelDefinition(level.getName(),new String[]{level.getName()},this.toStringArray(levelKeys));
    }
    createLeafLevel(levels,levelInHier,leafLevelKeyColumn);
    Object rowLimit=appContext.get(DataEngine.MEMORY_DATA_SET_CACHE);
    if (rowLimit != null && !cubeHandle.getDataSet().getName().equals(hierhandle.getDataSet().getName())) {
      appContext.remove(DataEngine.MEMORY_DATA_SET_CACHE);
      iHiers.add(cubeMaterializer.createHierarchy(dim.getName(),hierhandle.getName(),new DataSetIterator(this,queryMap.get(hierhandle),metaMap.get(hierhandle),appContext),levelInHier,stopSign));
      appContext.put(DataEngine.MEMORY_DATA_SET_CACHE,rowLimit);
    }
 else {
      iHiers.add(cubeMaterializer.createHierarchy(dim.getName(),hierhandle.getName(),new DataSetIterator(this,queryMap.get(hierhandle),metaMap.get(hierhandle),appContext),levelInHier,stopSign));
    }
  }
  return cubeMaterializer.createDimension(dim.getName(),(IHierarchy)iHiers.get(0));
}