Program: 69204
Project: 69204
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) {
    if (view.getCubeQueryDefinition() instanceof DrillCubeQueryDefinition) {
      DrillCubeQueryDefinition query=(DrillCubeQueryDefinition)view.getCubeQueryDefinition();
      for (int i=0; i < query.getLevelFilter().size(); i++) {
        cubeQueryExecutorHelper.addFilter((LevelFilter)query.getLevelFilter().get(i));
      }
    }
    rs=cubeQueryExecutorHelper.execute(aggrDefns,executor.getSession().getStopSign());
    CubeOperationsExecutor coe=new CubeOperationsExecutor(view.getCubeQueryDefinition(),view.getPreparedCubeOperations(),view.getCubeQueryExecutor().getScope(),view.getCubeQueryExecutor().getSession().getEngineContext().getScriptContext());
    rs=coe.execute(rs,stopSign);
    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) {
        AggregationResultSetSaveUtil.save(id,rs,executor.getContext().getDocWriter());
      }
 else {
        id=executor.getSession().getQueryResultIDUtil().nextID();
        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());
  }
  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;
  String id=null;
  CubeQueryExecutor executor=view.getCubeQueryExecutor();
  if (executor.getCubeQueryDefinition().getQueryResultsID() == null) {
    rs=cubeQueryExecutorHelper.execute(aggrDefns,executor.getSession().getStopSign());
    CubeOperationsExecutor coe=new CubeOperationsExecutor(view.getCubeQueryDefinition(),view.getPreparedCubeOperations(),view.getCubeQueryExecutor().getScope(),view.getCubeQueryExecutor().getSession().getEngineContext().getScriptContext());
    rs=coe.execute(rs,stopSign);
    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) {
        AggregationResultSetSaveUtil.save(id,rs,executor.getContext().getDocWriter());
      }
 else {
        id=executor.getSession().getQueryResultIDUtil().nextID();
        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());
  }
  executor.setQueryResultsId(id);
  return rs;
}