Program: 71629
Project: 71629
Buggy source:
/** 
 * Returns preview row data for table shared binding, it will share table's bindings and get them data.
 * @param headers
 * @param rowCount
 * @param isStringType
 * @return
 * @throws ChartException
 * @since 2.3
 */
private List getPreviewRowData(ColumnBindingInfo[] headers,int rowCount,boolean isStringType) throws ChartException {
  ArrayList dataList=new ArrayList();
  ClassLoader oldContextLoader=Thread.currentThread().getContextClassLoader();
  ClassLoader parentLoader=oldContextLoader;
  if (parentLoader == null)   parentLoader=this.getClass().getClassLoader();
  ClassLoader newContextLoader=DataSetProvider.getCustomScriptClassLoader(parentLoader,itemHandle.getModuleHandle());
  Thread.currentThread().setContextClassLoader(newContextLoader);
  ReportEngine engine=null;
  DummyEngineTask engineTask=null;
  DataRequestSession session=null;
  try {
    int maxRow=getMaxRow();
    if (isReportDesignHandle()) {
      engine=(ReportEngine)new ReportEngineFactory().createReportEngine(new EngineConfig());
      engineTask=new DummyEngineTask(engine,new ReportEngineHelper(engine).openReportDesign((ReportDesignHandle)itemHandle.getModuleHandle()));
      session=prepareDataRequestSession(engineTask,maxRow,false);
      engineTask.run();
    }
 else {
      session=prepareDataRequestSession(maxRow,false);
    }
    QueryDefinition queryDefn=new QueryDefinition();
    queryDefn.setMaxRows(maxRow);
    List columns=generateShareBindingsWithTable(headers,queryDefn,session,new HashMap());
    IQueryResults actualResultSet=session.executeQuery(queryDefn,null,getPropertyIterator(itemHandle.getPropertyHandle(ExtendedItemHandle.FILTER_PROP)),null);
    if (actualResultSet != null) {
      int columnCount=columns.size();
      IResultIterator iter=actualResultSet.getResultIterator();
      while (iter.next()) {
        if (isStringType) {
          String[] record=new String[columnCount];
          for (int n=0; n < columnCount; n++) {
            record[n]=DataTypeUtil.toString(iter.getValue((String)columns.get(n)));
          }
          dataList.add(record);
        }
 else {
          Object[] record=new Object[columnCount];
          for (int n=0; n < columnCount; n++) {
            record[n]=iter.getValue((String)columns.get(n));
          }
          dataList.add(record);
        }
      }
      actualResultSet.close();
    }
  }
 catch (  BirtException e) {
    throw new ChartException(ChartReportItemUIActivator.ID,ChartException.DATA_BINDING,e);
  }
 finally {
    Thread.currentThread().setContextClassLoader(oldContextLoader);
    if (engine == null && session != null) {
      session.shutdown();
    }
    if (engineTask != null) {
      engineTask.close();
    }
    if (engine != null) {
      engine.destroy();
    }
  }
  return dataList;
}

Fixed version (ground truth):
/** 
 * Returns preview row data for table shared binding, it will share table's bindings and get them data.
 * @param headers
 * @param rowCount
 * @param isStringType
 * @return
 * @throws ChartException
 * @since 2.3
 */
private List getPreviewRowData(ColumnBindingInfo[] headers,int rowCount,boolean isStringType) throws ChartException {
  ArrayList dataList=new ArrayList();
  ClassLoader oldContextLoader=Thread.currentThread().getContextClassLoader();
  ClassLoader parentLoader=oldContextLoader;
  if (parentLoader == null)   parentLoader=this.getClass().getClassLoader();
  ClassLoader newContextLoader=DataSetProvider.getCustomScriptClassLoader(parentLoader,itemHandle.getModuleHandle());
  Thread.currentThread().setContextClassLoader(newContextLoader);
  ReportEngine engine=null;
  DummyEngineTask engineTask=null;
  DataRequestSession session=null;
  try {
    int maxRow=getMaxRow();
    if (isReportDesignHandle()) {
      engine=(ReportEngine)new ReportEngineFactory().createReportEngine(new EngineConfig());
      engineTask=new DummyEngineTask(engine,new ReportEngineHelper(engine).openReportDesign((ReportDesignHandle)itemHandle.getModuleHandle()),itemHandle.getModuleHandle());
      session=prepareDataRequestSession(engineTask,maxRow,false);
      engineTask.run();
    }
 else {
      session=prepareDataRequestSession(maxRow,false);
    }
    QueryDefinition queryDefn=new QueryDefinition();
    queryDefn.setMaxRows(maxRow);
    List columns=generateShareBindingsWithTable(headers,queryDefn,session,new HashMap());
    IQueryResults actualResultSet=session.executeQuery(queryDefn,null,getPropertyIterator(itemHandle.getPropertyHandle(ExtendedItemHandle.FILTER_PROP)),null);
    if (actualResultSet != null) {
      int columnCount=columns.size();
      IResultIterator iter=actualResultSet.getResultIterator();
      while (iter.next()) {
        if (isStringType) {
          String[] record=new String[columnCount];
          for (int n=0; n < columnCount; n++) {
            record[n]=DataTypeUtil.toString(iter.getValue((String)columns.get(n)));
          }
          dataList.add(record);
        }
 else {
          Object[] record=new Object[columnCount];
          for (int n=0; n < columnCount; n++) {
            record[n]=iter.getValue((String)columns.get(n));
          }
          dataList.add(record);
        }
      }
      actualResultSet.close();
    }
  }
 catch (  BirtException e) {
    throw new ChartException(ChartReportItemUIActivator.ID,ChartException.DATA_BINDING,e);
  }
 finally {
    Thread.currentThread().setContextClassLoader(oldContextLoader);
    if (engine == null && session != null) {
      session.shutdown();
    }
    if (engineTask != null) {
      engineTask.close();
    }
    if (engine != null) {
      engine.destroy();
    }
  }
  return dataList;
}