Program: 77593
Project: 77593
Buggy source:
/** 
 * get selection choices from the data set.
 * @param dataSetName data set name
 * @param labelStmt label statement
 * @param valueStmt value statement
 * @param dataType value type
 * @return
 */
private Collection createDynamicSelectionChoices(String pattern,String dataSetName,String labelStmt,String valueStmt,String dataType,int limit,boolean fixedOrder){
  ArrayList choices=new ArrayList();
  ReportDesignHandle report=(ReportDesignHandle)this.runnable.getDesignHandle();
  DataSetHandle dataSet=report.findDataSet(dataSetName);
  if (dataSet != null) {
    try {
      IDataEngine dataEngine=executionContext.getDataEngine();
      DataEngine dteDataEngine=getDataEngine();
      dataEngine.defineDataSet(dataSet);
      ScriptExpression labelExpr=null;
      if (labelStmt != null && labelStmt.length() > 0) {
        labelExpr=new ScriptExpression(labelStmt);
      }
      ScriptExpression valueExpr=new ScriptExpression(valueStmt);
      QueryDefinition queryDefn=new QueryDefinition();
      queryDefn.setDataSetName(dataSetName);
      if (limit > 0) {
        queryDefn.setMaxRows(limit);
      }
      Iterator paramIter=dataSet.paramBindingsIterator();
      while (paramIter.hasNext()) {
        ParamBindingHandle binding=(ParamBindingHandle)paramIter.next();
        String paramName=binding.getParamName();
        String paramExpr=binding.getExpression();
        queryDefn.getInputParamBindings().add(new InputParameterBinding(paramName,new ScriptExpression(paramExpr)));
      }
      String labelColumnName=LABEL_PREFIX;
      ;
      String valueColumnName=VALUE_PREFIX;
      ;
      if (labelExpr != null) {
        queryDefn.addResultSetExpression(labelColumnName,labelExpr);
      }
      queryDefn.addResultSetExpression(valueColumnName,valueExpr);
      GroupDefinition groupDef=new GroupDefinition();
      groupDef.setKeyColumn(valueColumnName);
      queryDefn.addGroup(groupDef);
      queryDefn.setAutoBinding(true);
      IPreparedQuery query=dteDataEngine.prepare(queryDefn);
      IQueryResults result=query.execute(executionContext.getSharedScope());
      IResultIterator iter=result.getResultIterator();
      int count=0;
      while (iter.next()) {
        String label=null;
        if (labelExpr != null) {
          label=iter.getString(labelColumnName);
        }
        Object value=iter.getValue(valueColumnName);
        choices.add(new SelectionChoice(label,convertToType(value,dataType)));
        count++;
        if ((limit != 0) && (count >= limit)) {
          break;
        }
        iter.skipToEnd(1);
      }
    }
 catch (    BirtException ex) {
      ex.printStackTrace();
    }
  }
  if (!fixedOrder)   Collections.sort(choices,new SelectionChoiceComparator(true,pattern,ULocale.forLocale(locale)));
  return choices;
}

Fixed version (ground truth):
/** 
 * get selection choices from the data set.
 * @param dataSetName data set name
 * @param labelStmt label statement
 * @param valueStmt value statement
 * @param dataType value type
 * @return
 */
private Collection createDynamicSelectionChoices(String pattern,String dataSetName,String labelStmt,String valueStmt,String dataType,int limit,boolean fixedOrder){
  ArrayList choices=new ArrayList();
  ReportDesignHandle report=(ReportDesignHandle)this.runnable.getDesignHandle();
  DataSetHandle dataSet=report.findDataSet(dataSetName);
  if (dataSet != null) {
    try {
      IDataEngine dataEngine=executionContext.getDataEngine();
      DataEngine dteDataEngine=getDataEngine();
      dataEngine.defineDataSet(dataSet);
      ScriptExpression labelExpr=null;
      if (labelStmt != null && labelStmt.length() > 0) {
        labelExpr=new ScriptExpression(labelStmt);
      }
      ScriptExpression valueExpr=new ScriptExpression(valueStmt);
      QueryDefinition queryDefn=new QueryDefinition();
      queryDefn.setDataSetName(dataSetName);
      if (limit > 0) {
        queryDefn.setMaxRows(limit);
      }
      Iterator paramIter=dataSet.paramBindingsIterator();
      while (paramIter.hasNext()) {
        ParamBindingHandle binding=(ParamBindingHandle)paramIter.next();
        String paramName=binding.getParamName();
        String paramExpr=binding.getExpression();
        queryDefn.getInputParamBindings().add(new InputParameterBinding(paramName,new ScriptExpression(paramExpr)));
      }
      String labelColumnName=LABEL_PREFIX;
      ;
      String valueColumnName=VALUE_PREFIX;
      ;
      if (labelExpr != null) {
        queryDefn.addResultSetExpression(labelColumnName,labelExpr);
      }
      queryDefn.addResultSetExpression(valueColumnName,valueExpr);
      GroupDefinition groupDef=new GroupDefinition();
      groupDef.setKeyColumn(valueColumnName);
      queryDefn.addGroup(groupDef);
      queryDefn.setAutoBinding(true);
      IPreparedQuery query=dteDataEngine.prepare(queryDefn,this.appContext);
      IQueryResults result=query.execute(executionContext.getSharedScope());
      IResultIterator iter=result.getResultIterator();
      int count=0;
      while (iter.next()) {
        String label=null;
        if (labelExpr != null) {
          label=iter.getString(labelColumnName);
        }
        Object value=iter.getValue(valueColumnName);
        choices.add(new SelectionChoice(label,convertToType(value,dataType)));
        count++;
        if ((limit != 0) && (count >= limit)) {
          break;
        }
        iter.skipToEnd(1);
      }
    }
 catch (    BirtException ex) {
      ex.printStackTrace();
    }
  }
  if (!fixedOrder)   Collections.sort(choices,new SelectionChoiceComparator(true,pattern,ULocale.forLocale(locale)));
  return choices;
}