Program: 78703
Project: 78703
Buggy source:
/** 
 * The first step to work with the cascading parameters. Create the query definition, prepare and execute the query. Cache the iterator of the result set and also cache the IBaseExpression used in the prepare.
 * @param parameterGroupName -the cascading parameter group name
 */
public void evaluateQuery(String parameterGroupName){
  CascadingParameterGroupHandle parameterGroup=getCascadingParameterGroup(parameterGroupName);
  if (dataCache == null)   dataCache=new HashMap();
  if (parameterGroup == null)   return;
  DataSetHandle dataSet=parameterGroup.getDataSet();
  if (dataSet != null) {
    try {
      DataEngine dataEngine=getDataEngine();
      DataSourceHandle dataSource=dataSet.getDataSource();
      ModelDteApiAdapter adaptor=new ModelDteApiAdapter(executionContext.getReportContext(),executionContext.getSharedScope());
      try {
        dataEngine.defineDataSource(adaptor.createDataSourceDesign(dataSource));
        dataEngine.defineDataSet(adaptor.createDataSetDesign(dataSet));
      }
 catch (      BirtException e) {
        log.log(Level.SEVERE,e.getMessage());
      }
      QueryDefinition queryDefn=new QueryDefinition();
      queryDefn.setDataSetName(dataSet.getQualifiedName());
      SlotHandle parameters=parameterGroup.getParameters();
      Iterator iter=parameters.iterator();
      if (labelMap == null)       labelMap=new HashMap();
      if (valueMap == null)       valueMap=new HashMap();
      while (iter.hasNext()) {
        Object param=iter.next();
        if (param instanceof ScalarParameterHandle) {
          String valueExpString=((ScalarParameterHandle)param).getValueExpr();
          Object valueExpObject=new ScriptExpression(valueExpString);
          valueMap.put(parameterGroup.getName() + "String_Node_Str" + ((ScalarParameterHandle)param).getName(),valueExpObject);
          queryDefn.getRowExpressions().add(valueExpObject);
          String labelExpString=((ScalarParameterHandle)param).getLabelExpr();
          if (labelExpString != null && labelExpString.length() > 0) {
            Object labelExpObject=new ScriptExpression(labelExpString);
            labelMap.put(parameterGroup.getName() + "String_Node_Str" + ((ScalarParameterHandle)param).getName(),labelExpObject);
            queryDefn.getRowExpressions().add(labelExpObject);
          }
          GroupDefinition groupDef=new GroupDefinition();
          groupDef.setKeyExpression(valueExpString);
          queryDefn.addGroup(groupDef);
        }
      }
      IPreparedQuery query=dataEngine.prepare(queryDefn);
      IQueryResults result=query.execute(executionContext.getSharedScope());
      IResultIterator resultIter=result.getResultIterator();
      dataCache.put(parameterGroup.getName(),resultIter);
      return;
    }
 catch (    BirtException ex) {
      ex.printStackTrace();
    }
  }
  dataCache.put(parameterGroup.getName(),null);
}

Fixed version (ground truth):
/** 
 * The first step to work with the cascading parameters. Create the query definition, prepare and execute the query. Cache the iterator of the result set and also cache the IBaseExpression used in the prepare.
 * @param parameterGroupName -the cascading parameter group name
 */
public void evaluateQuery(String parameterGroupName){
  CascadingParameterGroupHandle parameterGroup=getCascadingParameterGroup(parameterGroupName);
  if (dataCache == null)   dataCache=new HashMap();
  if (parameterGroup == null)   return;
  DataSetHandle dataSet=parameterGroup.getDataSet();
  if (dataSet != null) {
    try {
      DataEngine dataEngine=getDataEngine();
      DataSourceHandle dataSource=dataSet.getDataSource();
      ModelDteApiAdapter adaptor=new ModelDteApiAdapter(executionContext,executionContext.getSharedScope());
      try {
        dataEngine.defineDataSource(adaptor.createDataSourceDesign(dataSource));
        dataEngine.defineDataSet(adaptor.createDataSetDesign(dataSet));
      }
 catch (      BirtException e) {
        log.log(Level.SEVERE,e.getMessage());
      }
      QueryDefinition queryDefn=new QueryDefinition();
      queryDefn.setDataSetName(dataSet.getQualifiedName());
      SlotHandle parameters=parameterGroup.getParameters();
      Iterator iter=parameters.iterator();
      if (labelMap == null)       labelMap=new HashMap();
      if (valueMap == null)       valueMap=new HashMap();
      while (iter.hasNext()) {
        Object param=iter.next();
        if (param instanceof ScalarParameterHandle) {
          String valueExpString=((ScalarParameterHandle)param).getValueExpr();
          Object valueExpObject=new ScriptExpression(valueExpString);
          valueMap.put(parameterGroup.getName() + "String_Node_Str" + ((ScalarParameterHandle)param).getName(),valueExpObject);
          queryDefn.getRowExpressions().add(valueExpObject);
          String labelExpString=((ScalarParameterHandle)param).getLabelExpr();
          if (labelExpString != null && labelExpString.length() > 0) {
            Object labelExpObject=new ScriptExpression(labelExpString);
            labelMap.put(parameterGroup.getName() + "String_Node_Str" + ((ScalarParameterHandle)param).getName(),labelExpObject);
            queryDefn.getRowExpressions().add(labelExpObject);
          }
          GroupDefinition groupDef=new GroupDefinition();
          groupDef.setKeyExpression(valueExpString);
          queryDefn.addGroup(groupDef);
        }
      }
      IPreparedQuery query=dataEngine.prepare(queryDefn);
      IQueryResults result=query.execute(executionContext.getSharedScope());
      IResultIterator resultIter=result.getResultIterator();
      dataCache.put(parameterGroup.getName(),resultIter);
      return;
    }
 catch (    BirtException ex) {
      ex.printStackTrace();
    }
  }
  dataCache.put(parameterGroup.getName(),null);
}