Program: 77592
Project: 77592
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;
  IResultIterator iterOld=(IResultIterator)dataCache.get(parameterGroup.getName());
  if (iterOld != null) {
    dataCache.remove(parameterGroup.getName());
    try {
      IQueryResults iresultOld=iterOld.getQueryResults();
      iterOld.close();
      iresultOld.close();
    }
 catch (    BirtException ex) {
      log.log(Level.WARNING,ex.getMessage());
    }
  }
  DataSetHandle dataSet=parameterGroup.getDataSet();
  if (dataSet != null) {
    try {
      DataEngine dteDataEngine=getDataEngine();
      IDataEngine dataEngine=executionContext.getDataEngine();
      dataEngine.defineDataSet(dataSet);
      QueryDefinition queryDefn=new QueryDefinition();
      queryDefn.setDataSetName(dataSet.getQualifiedName());
      SlotHandle parameters=parameterGroup.getParameters();
      Iterator iter=parameters.iterator();
      if (labelColumnBindingNames == null)       labelColumnBindingNames=new ArrayList();
      while (iter.hasNext()) {
        Object param=iter.next();
        if (param instanceof ScalarParameterHandle) {
          String valueExpString=((ScalarParameterHandle)param).getValueExpr();
          ScriptExpression valueExpObject=new ScriptExpression(valueExpString);
          String keyValue=VALUE_PREFIX + parameterGroup.getName() + "String_Node_Str"+ ((ScalarParameterHandle)param).getName();
          queryDefn.addResultSetExpression(keyValue,valueExpObject);
          String labelExpString=((ScalarParameterHandle)param).getLabelExpr();
          if (labelExpString != null && labelExpString.length() > 0) {
            ScriptExpression labelExpObject=new ScriptExpression(labelExpString);
            String keyLabel=LABEL_PREFIX + parameterGroup.getName() + "String_Node_Str"+ ((ScalarParameterHandle)param).getName();
            labelColumnBindingNames.add(keyLabel);
            queryDefn.addResultSetExpression(keyLabel,labelExpObject);
          }
          GroupDefinition groupDef=new GroupDefinition();
          groupDef.setKeyExpression(valueExpString);
          queryDefn.addGroup(groupDef);
        }
      }
      queryDefn.setAutoBinding(true);
      IPreparedQuery query=dteDataEngine.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;
  IResultIterator iterOld=(IResultIterator)dataCache.get(parameterGroup.getName());
  if (iterOld != null) {
    dataCache.remove(parameterGroup.getName());
    try {
      IQueryResults iresultOld=iterOld.getQueryResults();
      iterOld.close();
      iresultOld.close();
    }
 catch (    BirtException ex) {
      log.log(Level.WARNING,ex.getMessage());
    }
  }
  DataSetHandle dataSet=parameterGroup.getDataSet();
  if (dataSet != null) {
    try {
      DataEngine dteDataEngine=getDataEngine();
      IDataEngine dataEngine=executionContext.getDataEngine();
      dataEngine.defineDataSet(dataSet);
      QueryDefinition queryDefn=new QueryDefinition();
      queryDefn.setDataSetName(dataSet.getQualifiedName());
      SlotHandle parameters=parameterGroup.getParameters();
      Iterator iter=parameters.iterator();
      if (labelColumnBindingNames == null)       labelColumnBindingNames=new ArrayList();
      while (iter.hasNext()) {
        Object param=iter.next();
        if (param instanceof ScalarParameterHandle) {
          String valueExpString=((ScalarParameterHandle)param).getValueExpr();
          ScriptExpression valueExpObject=new ScriptExpression(valueExpString);
          String keyValue=VALUE_PREFIX + parameterGroup.getName() + "String_Node_Str"+ ((ScalarParameterHandle)param).getName();
          queryDefn.addResultSetExpression(keyValue,valueExpObject);
          String labelExpString=((ScalarParameterHandle)param).getLabelExpr();
          if (labelExpString != null && labelExpString.length() > 0) {
            ScriptExpression labelExpObject=new ScriptExpression(labelExpString);
            String keyLabel=LABEL_PREFIX + parameterGroup.getName() + "String_Node_Str"+ ((ScalarParameterHandle)param).getName();
            labelColumnBindingNames.add(keyLabel);
            queryDefn.addResultSetExpression(keyLabel,labelExpObject);
          }
          GroupDefinition groupDef=new GroupDefinition();
          groupDef.setKeyExpression(valueExpString);
          queryDefn.addGroup(groupDef);
        }
      }
      queryDefn.setAutoBinding(true);
      IPreparedQuery query=dteDataEngine.prepare(queryDefn,this.appContext);
      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);
}