Program: 67904
Project: 67904
Buggy source:
/** 
 * This method executes IQueryDefinition, ICubeQueryDefinition and ISubCubeQueryDefinition; ISubqueryDefinition is not included here.
 */
static public IBaseQueryResults executeQuery(IBaseQueryResults parent,IDataQueryDefinition query,String rset,ExecutionContext executionContext) throws EngineException {
  try {
    DataRequestSession dataSession=executionContext.getDataEngine().getDTESession();
    if (dataSession == null)     return null;
    Map appContext=executionContext.getAppContext();
    ScriptContext scriptContext=executionContext.getScriptContext();
    processQueryExtensions(query,executionContext);
    if (query instanceof QueryDefinition) {
      QueryDefinition tmpQuery=(QueryDefinition)query;
      tmpQuery.setQueryResultsID(rset);
      IPreparedQuery pQuery=dataSession.prepare(tmpQuery,appContext);
      if (pQuery == null)       return null;
      return dataSession.execute(pQuery,parent,scriptContext);
    }
 else     if (query instanceof ICubeQueryDefinition) {
      ICubeQueryDefinition cubeQuery=(ICubeQueryDefinition)query;
      cubeQuery.setQueryResultsID(rset);
      IPreparedCubeQuery pQuery=dataSession.prepare(cubeQuery,appContext);
      if (pQuery == null)       return null;
      return dataSession.execute(pQuery,parent,scriptContext);
    }
 else     if (query instanceof ISubCubeQueryDefinition) {
      ISubCubeQueryDefinition cubeQuery=(ISubCubeQueryDefinition)query;
      IPreparedCubeQuery pQuery=dataSession.prepare(cubeQuery,appContext);
      if (pQuery == null)       return null;
      return dataSession.execute(pQuery,parent,scriptContext);
    }
  }
 catch (  BirtException ex) {
    throw new EngineException(ex);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * This method executes IQueryDefinition, ICubeQueryDefinition and ISubCubeQueryDefinition; ISubqueryDefinition is not included here.
 */
static public IBaseQueryResults executeQuery(IBaseQueryResults parent,IDataQueryDefinition query,String rset,ExecutionContext executionContext) throws EngineException {
  try {
    DataRequestSession dataSession=executionContext.getDataEngine().getDTESession();
    if (dataSession == null)     return null;
    Map appContext=executionContext.getAppContext();
    dataSession.getDataSessionContext().setAppContext(appContext);
    ScriptContext scriptContext=executionContext.getScriptContext();
    processQueryExtensions(query,executionContext);
    if (query instanceof QueryDefinition) {
      QueryDefinition tmpQuery=(QueryDefinition)query;
      tmpQuery.setQueryResultsID(rset);
      IPreparedQuery pQuery=dataSession.prepare(tmpQuery);
      if (pQuery == null)       return null;
      return dataSession.execute(pQuery,parent,scriptContext);
    }
 else     if (query instanceof ICubeQueryDefinition) {
      ICubeQueryDefinition cubeQuery=(ICubeQueryDefinition)query;
      cubeQuery.setQueryResultsID(rset);
      IPreparedCubeQuery pQuery=dataSession.prepare(cubeQuery);
      if (pQuery == null)       return null;
      return dataSession.execute(pQuery,parent,scriptContext);
    }
 else     if (query instanceof ISubCubeQueryDefinition) {
      ISubCubeQueryDefinition cubeQuery=(ISubCubeQueryDefinition)query;
      IPreparedCubeQuery pQuery=dataSession.prepare(cubeQuery);
      if (pQuery == null)       return null;
      return dataSession.execute(pQuery,parent,scriptContext);
    }
  }
 catch (  BirtException ex) {
    throw new EngineException(ex);
  }
  return null;
}