Program: 66505
Project: 66505
Buggy source:
/** 
 * Used in the filter select value dialog in dataset editor
 * @param expression
 * @param dataSetHandle
 * @param binding
 * @param useDataSetFilter
 * @return
 * @throws BirtException
 */
public static List getSelectValueList(Expression expression,DataSetHandle dataSetHandle,boolean useDataSetFilter) throws BirtException {
  ScriptExpression expr=null;
  DataSetHandle targetHandle=dataSetHandle;
  Map appContext=new HashMap();
  DataSetPreviewer previewer=null;
  try {
    if (!useDataSetFilter) {
      IDesignElement element=dataSetHandle.copy();
      ((DataSet)element).setProperty(IDataSetModel.FILTER_PROP,new ArrayList());
      targetHandle=ExternalUIUtil.newDataSetHandle(dataSetHandle,(DesignElement)element);
    }
    previewer=new DataSetPreviewer(targetHandle,0,PreviewType.RESULTSET);
    DataModelAdapter adapter=new DataModelAdapter(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION,targetHandle.getModuleHandle()));
    expr=adapter.adaptExpression(expression);
    boolean startsWithRow=ExpressionUtility.isColumnExpression(expr.getText(),true);
    boolean startsWithDataSetRow=ExpressionUtility.isColumnExpression(expr.getText(),false);
    if (!startsWithRow && !startsWithDataSetRow) {
      throw new DataException(Messages.getString("String_Node_Str"));
    }
    String dataSetColumnName=null;
    if (startsWithDataSetRow) {
      dataSetColumnName=ExpressionUtil.getColumnName(expr.getText());
    }
 else {
      dataSetColumnName=ExpressionUtil.getColumnBindingName(expr.getText());
    }
    ResourceIdentifiers identifiers=new ResourceIdentifiers();
    String resouceIDs=ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS;
    identifiers.setApplResourceBaseURI(DTPUtil.getInstance().getBIRTResourcePath());
    identifiers.setDesignResourceBaseURI(DTPUtil.getInstance().getReportDesignPath());
    appContext.put(resouceIDs,identifiers);
    AppContextPopulator.populateApplicationContext(targetHandle,appContext);
    previewer.open(appContext,getEngineConfig(targetHandle.getModuleHandle()));
    IResultIterator itr=previewer.preview();
    Set visitedValues=new HashSet();
    Object value=null;
    while (itr.next()) {
      if (visitedValues.size() > 10000) {
        break;
      }
      value=itr.getValue(dataSetColumnName);
      if (!visitedValues.contains(value)) {
        visitedValues.add(value);
      }
    }
    if (visitedValues.isEmpty())     return Collections.EMPTY_LIST;
    return new ArrayList(visitedValues);
  }
  finally {
    AppContextResourceReleaser.release(appContext);
    if (previewer != null)     previewer.close();
  }
}

Fixed version (ground truth):
/** 
 * Used in the filter select value dialog in dataset editor
 * @param expression
 * @param dataSetHandle
 * @param binding
 * @param useDataSetFilter
 * @return
 * @throws BirtException
 */
public static List getSelectValueList(Expression expression,DataSetHandle dataSetHandle,boolean useDataSetFilter) throws BirtException {
  ScriptExpression expr=null;
  DataSetHandle targetHandle=dataSetHandle;
  Map appContext=new HashMap();
  DataSetPreviewer previewer=null;
  try {
    if (!useDataSetFilter) {
      IDesignElement element=dataSetHandle.copy();
      ((DataSet)element).setProperty(IDataSetModel.FILTER_PROP,new ArrayList());
      targetHandle=ExternalUIUtil.newDataSetHandle(dataSetHandle,(DesignElement)element);
    }
    previewer=new DataSetPreviewer(targetHandle,0,PreviewType.RESULTSET);
    DataModelAdapter adapter=new DataModelAdapter(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION,targetHandle.getModuleHandle()));
    expr=adapter.adaptExpression(expression);
    boolean startsWithRow=ExpressionUtility.isColumnExpression(expr.getText(),true);
    boolean startsWithDataSetRow=ExpressionUtility.isColumnExpression(expr.getText(),false);
    if (!startsWithRow && !startsWithDataSetRow) {
      throw new DataException(Messages.getString("String_Node_Str"));
    }
    String dataSetColumnName=null;
    if (startsWithDataSetRow) {
      dataSetColumnName=ExpressionUtil.getColumnName(expr.getText());
    }
 else {
      dataSetColumnName=ExpressionUtil.getColumnBindingName(expr.getText());
    }
    ResourceIdentifiers identifiers=new ResourceIdentifiers();
    String resouceIDs=ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS;
    identifiers.setApplResourceBaseURI(DTPUtil.getInstance().getBIRTResourcePath());
    identifiers.setDesignResourceBaseURI(DTPUtil.getInstance().getReportDesignPath());
    appContext.put(resouceIDs,identifiers);
    AppContextPopulator.populateApplicationContext(targetHandle,appContext);
    previewer.open(appContext,getEngineConfig(targetHandle.getModuleHandle()));
    IResultIterator itr=previewer.preview();
    Set visitedValues=new HashSet();
    Object value=null;
    while (itr.next()) {
      if (visitedValues.size() > 10000) {
        break;
      }
      value=itr.getValue(dataSetColumnName);
      if (value != null && !visitedValues.contains(value)) {
        visitedValues.add(value);
      }
    }
    if (visitedValues.isEmpty())     return Collections.EMPTY_LIST;
    return new ArrayList(visitedValues);
  }
  finally {
    AppContextResourceReleaser.release(appContext);
    if (previewer != null)     previewer.close();
  }
}