Program: 66640
Project: 66640
Buggy source:
/** 
 * update output parameter table result
 */
private void updateResults(){
  int outputParamsSize=outputParametersSize();
  if (outputParamsSize == 0)   return;
  DataRequestSession session=null;
  try {
    ModuleHandle handle=null;
    DataSetHandle dsHandle=((DataSetEditor)getContainer()).getHandle();
    handle=dsHandle.getModuleHandle();
    EngineConfig ec=new EngineConfig();
    ClassLoader parent=Thread.currentThread().getContextClassLoader();
    if (parent == null) {
      parent=this.getClass().getClassLoader();
    }
    ClassLoader customClassLoader=DataSetProvider.getCustomScriptClassLoader(parent,handle);
    ec.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,customClassLoader);
    ReportDesignHandle copiedReport=(ReportDesignHandle)(handle.copy().getHandle(null));
    ReportEngine engine=(ReportEngine)new ReportEngineFactory().createReportEngine(ec);
    DummyEngineTask engineTask=new DummyEngineTask(engine,new ReportEngineHelper(engine).openReportDesign(copiedReport),copiedReport);
    Map appContext=new HashMap();
    appContext.put(DataEngine.MEMORY_DATA_SET_CACHE,Integer.valueOf(((DataSetHandle)getContainer().getModel()).getRowFetchLimit()));
    engineTask.setAppContext(appContext);
    engineTask.run();
    session=engineTask.getDataSession();
    QueryDefinition query=new QueryDefinition();
    query.setDataSetName(((DataSetEditor)getContainer()).getHandle().getQualifiedName());
    query.setMaxRows(1);
    PropertyHandle propertyHandle=((DataSetEditor)getContainer()).getHandle().getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
    int paramsSize=propertyHandle.getListValue().size();
    Iterator paramIter=propertyHandle.iterator();
    int outputParamIndex=0;
    TableLayout layout=new TableLayout();
    TableColumn column=null;
    TableItem tableItem=null;
    List paramColumnBindingNames=new ArrayList();
    for (int n=1; n <= paramsSize; n++) {
      DataSetParameterHandle paramDefn=(DataSetParameterHandle)paramIter.next();
      if (!paramDefn.isOutput())       continue;
      column=new TableColumn(outputParameterTable,SWT.LEFT);
      column.setText(paramDefn.getName());
      column.setResizable(true);
      layout.addColumnData(new ColumnPixelData(120,true));
      String bindingName=PREFIX_PARAMETER + (outputParamIndex++);
      IBinding binding=new Binding(bindingName);
      binding.setExpression(new ScriptExpression(PREFIX_OUTPUTPARAMETER + "String_Node_Str" + paramDefn.getName()+ "String_Node_Str"));
      binding.setDataType(DataAdapterUtil.adaptModelDataType(paramDefn.getDataType()));
      paramColumnBindingNames.add(bindingName);
      query.addBinding(binding);
      column.pack();
    }
    outputParameterTable.setLayout(layout);
    outputParameterTable.layout(true);
    DataSetExecutorHelper helper=new DataSetExecutorHelper();
    IQueryResults actualResultSet=helper.execute(((DataSetEditor)getContainer()).getHandle(),query,true,true,session);
    if (actualResultSet != null) {
      IResultIterator iter=actualResultSet.getResultIterator();
      iter.next();
      String[] record=new String[outputParamIndex];
      for (int n=0; n < record.length; n++) {
        record[n]=iter.getString(paramColumnBindingNames.get(n).toString());
      }
      tableItem=new TableItem(outputParameterTable,SWT.NONE);
      tableItem.setText(record);
      actualResultSet.close();
    }
  }
 catch (  BirtException ex) {
    ExceptionHandler.handle(ex);
  }
 finally {
    if (session != null) {
      session.shutdown();
    }
  }
}

Fixed version (ground truth):
/** 
 * update output parameter table result
 */
private void updateResults(){
  int outputParamsSize=outputParametersSize();
  if (outputParamsSize == 0)   return;
  DataRequestSession session=null;
  try {
    ModuleHandle handle=null;
    DataSetHandle dsHandle=((DataSetEditor)getContainer()).getHandle();
    handle=dsHandle.getModuleHandle();
    EngineConfig ec=new EngineConfig();
    ClassLoader parent=Thread.currentThread().getContextClassLoader();
    if (parent == null) {
      parent=this.getClass().getClassLoader();
    }
    ClassLoader customClassLoader=DataSetProvider.getCustomScriptClassLoader(parent,handle);
    ec.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,customClassLoader);
    ReportDesignHandle copiedReport=(ReportDesignHandle)(handle.copy().getHandle(null));
    ReportEngine engine=(ReportEngine)new ReportEngineFactory().createReportEngine(ec);
    DummyEngineTask engineTask=new DummyEngineTask(engine,new ReportEngineHelper(engine).openReportDesign(copiedReport),copiedReport,dsHandle);
    Map appContext=new HashMap();
    appContext.put(DataEngine.MEMORY_DATA_SET_CACHE,Integer.valueOf(((DataSetHandle)getContainer().getModel()).getRowFetchLimit()));
    engineTask.setAppContext(appContext);
    engineTask.run();
    session=engineTask.getDataSession();
    QueryDefinition query=new QueryDefinition();
    query.setDataSetName(((DataSetEditor)getContainer()).getHandle().getQualifiedName());
    query.setMaxRows(1);
    PropertyHandle propertyHandle=((DataSetEditor)getContainer()).getHandle().getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
    int paramsSize=propertyHandle.getListValue().size();
    Iterator paramIter=propertyHandle.iterator();
    int outputParamIndex=0;
    TableLayout layout=new TableLayout();
    TableColumn column=null;
    TableItem tableItem=null;
    List paramColumnBindingNames=new ArrayList();
    for (int n=1; n <= paramsSize; n++) {
      DataSetParameterHandle paramDefn=(DataSetParameterHandle)paramIter.next();
      if (!paramDefn.isOutput())       continue;
      column=new TableColumn(outputParameterTable,SWT.LEFT);
      column.setText(paramDefn.getName());
      column.setResizable(true);
      layout.addColumnData(new ColumnPixelData(120,true));
      String bindingName=PREFIX_PARAMETER + (outputParamIndex++);
      IBinding binding=new Binding(bindingName);
      binding.setExpression(new ScriptExpression(PREFIX_OUTPUTPARAMETER + "String_Node_Str" + paramDefn.getName()+ "String_Node_Str"));
      binding.setDataType(DataAdapterUtil.adaptModelDataType(paramDefn.getDataType()));
      paramColumnBindingNames.add(bindingName);
      query.addBinding(binding);
      column.pack();
    }
    outputParameterTable.setLayout(layout);
    outputParameterTable.layout(true);
    DataSetExecutorHelper helper=new DataSetExecutorHelper();
    IQueryResults actualResultSet=helper.execute(((DataSetEditor)getContainer()).getHandle(),query,true,true,session);
    if (actualResultSet != null) {
      IResultIterator iter=actualResultSet.getResultIterator();
      iter.next();
      String[] record=new String[outputParamIndex];
      for (int n=0; n < record.length; n++) {
        record[n]=iter.getString(paramColumnBindingNames.get(n).toString());
      }
      tableItem=new TableItem(outputParameterTable,SWT.NONE);
      tableItem.setText(record);
      actualResultSet.close();
    }
  }
 catch (  BirtException ex) {
    ExceptionHandler.handle(ex);
  }
 finally {
    if (session != null) {
      session.shutdown();
    }
  }
}