Program: 66431
Project: 66431
Buggy source:
private IAggregationResultSet[] populateRs(BirtCubeView view,AggregationDefinition[] aggrDefns,CubeQueryExecutorHelper cubeQueryExcutorHelper2,StopSign stopSign,boolean saveToRD) throws IOException, BirtException {
  IAggregationResultSet[] rs;
  String id=null;
  CubeQueryExecutor executor=view.getCubeQueryExecutor();
  if (executor.getCubeQueryDefinition().getQueryResultsID() == null) {
    rs=cubeQueryExecutorHelper.execute(aggrDefns,executor.getSession().getStopSign());
    MirrorOperationExecutor moe=new MirrorOperationExecutor();
    rs=moe.execute(rs,view,cubeQueryExecutorHelper);
    if (executor.getCubeQueryDefinition().cacheQueryResults()) {
      id=executor.getSession().getQueryResultIDUtil().nextID();
      File tmpDir=new File(executor.getSession().getTempDir());
      if (!FileSecurity.fileExist(tmpDir) || !FileSecurity.fileIsDirectory(tmpDir)) {
        FileSecurity.fileMakeDirs(tmpDir);
      }
      ArchiveWriter writer=new ArchiveWriter(new ArchiveFile(executor.getSession().getTempDir() + "String_Node_Str","String_Node_Str"));
      AggregationResultSetSaveUtil.save(id,rs,writer);
      writer.finish();
    }
    if (saveToRD) {
      if (id != null) {
        CubeQueryDefinitionIOUtil.save(id,executor.getContext().getDocWriter(),executor.getCubeQueryDefinition());
        AggregationResultSetSaveUtil.save(id,rs,executor.getContext().getDocWriter());
      }
 else {
        id=executor.getSession().getQueryResultIDUtil().nextID();
        CubeQueryDefinitionIOUtil.save(id,executor.getContext().getDocWriter(),executor.getCubeQueryDefinition());
        AggregationResultSetSaveUtil.save(id,rs,executor.getContext().getDocWriter());
      }
    }
  }
 else {
    id=executor.getCubeQueryDefinition().getQueryResultsID();
    rs=AggregationResultSetSaveUtil.load(id,new FileArchiveReader(executor.getSession().getTempDir() + "String_Node_Str"),VersionManager.getLatestVersion(),cubeQueryExecutorHelper.getMemoryCacheSize());
    initLoadedAggregationResultSets(rs,aggrDefns);
  }
  executor.setQueryResultsId(id);
  return rs;
}

Fixed version (ground truth):
private IAggregationResultSet[] populateRs(BirtCubeView view,AggregationDefinition[] aggrDefns,CubeQueryExecutorHelper cubeQueryExcutorHelper2,StopSign stopSign,boolean saveToRD) throws IOException, BirtException {
  IAggregationResultSet[] rs=null;
  String id=null;
  CubeQueryExecutor executor=view.getCubeQueryExecutor();
  if (executor.getCubeQueryDefinition().getQueryResultsID() == null) {
    if (saveToRD || executor.getCubeQueryDefinition().cacheQueryResults())     id=executor.getSession().getQueryResultIDUtil().nextID();
    rs=executeQuery(view,aggrDefns,saveToRD,id);
  }
 else {
    id=executor.getCubeQueryDefinition().getQueryResultsID();
    if (executor.getCubeQueryDefinition().cacheQueryResults()) {
      rs=AggregationResultSetSaveUtil.load(id,new FileArchiveReader(executor.getSession().getTempDir() + "String_Node_Str"),VersionManager.getLatestVersion(),cubeQueryExecutorHelper.getMemoryCacheSize());
      initLoadedAggregationResultSets(rs,aggrDefns);
    }
 else {
      if (executor.getContext().getDocReader() != null) {
        rs=AggregationResultSetSaveUtil.load(executor.getCubeQueryDefinition().getQueryResultsID(),executor.getContext().getDocReader(),new VersionManager(executor.getContext()).getVersion(),cubeQueryExecutorHelper.getMemoryCacheSize());
        initLoadedAggregationResultSets(rs,aggrDefns);
      }
 else {
        rs=executeQuery(view,aggrDefns,saveToRD,id);
      }
    }
  }
  executor.setQueryResultsId(id);
  return rs;
}