Program: 66424
Project: 66424
Buggy source:
/** 
 * populate output columns
 * @throws BirtException
 */
protected void populateOutputColums() throws BirtException {
  ClassLoader oldContextLoader=Thread.currentThread().getContextClassLoader();
  ClassLoader parentLoader=oldContextLoader;
  if (parentLoader == null)   parentLoader=this.getClass().getClassLoader();
  ClassLoader newContextLoader=DataSetProvider.getCustomScriptClassLoader(parentLoader,((DataSetEditor)getContainer()).getHandle().getModuleHandle());
  ModuleHandle handle=((DataSetEditor)getContainer()).getHandle().getModuleHandle();
  DataSessionContext context;
  if (handle instanceof ReportDesignHandle) {
    Map dataSetMap=new HashMap();
    Map dataSourceMap=new HashMap();
    DummyEngineTask engineTask=null;
    DataRequestSession session=null;
    ReportEngine engine=null;
    try {
      EngineConfig ec=new EngineConfig();
      ec.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,newContextLoader);
      engine=(ReportEngine)new ReportEngineFactory().createReportEngine(ec);
      DataSetMetaDataHelper.clearPropertyBindingMap(((DataSetEditor)getContainer()).getHandle(),dataSetMap,dataSourceMap);
      ReportDesignHandle copy=(ReportDesignHandle)(handle.copy().getHandle(null));
      engineTask=new DummyEngineTask(engine,new ReportEngineHelper(engine).openReportDesign((ReportDesignHandle)copy),copy);
      session=engineTask.getDataSession();
      engineTask.run();
      DataSetViewData[] viewDatas=DataSetProvider.getCurrentInstance().populateAllOutputColumns(((DataSetEditor)getContainer()).getHandle(),session);
      if (viewDatas == null) {
        viewDatas=((DataSetEditor)getContainer()).getCurrentItemModel(false,false);
      }
      updateDefaultPropertyValues(viewDatas);
      if (isNewlyCreated) {
        updateAnalysisTypes(viewDatas,true);
      }
      if (((DataSetEditor)getContainer()).getHandle() instanceof JointDataSetHandle) {
        PropertyHandle properyHandle=((DataSetEditor)getContainer()).getHandle().getPropertyHandle(DataSetHandle.COLUMN_HINTS_PROP);
        if (properyHandle != null) {
          for (int i=0; i < viewDatas.length; i++) {
            for (Iterator columns=properyHandle.iterator(); columns.hasNext(); ) {
              ColumnHintHandle column=(ColumnHintHandle)columns.next();
              if (viewDatas[i].getName().equals(column.getColumnName())) {
                viewDatas[i].setAlias(column.getAlias());
                break;
              }
            }
          }
        }
      }
      viewer.getViewer().setInput(viewDatas);
    }
  finally {
      session.shutdown();
      engineTask.close();
      engine.destroy();
      DataSetMetaDataHelper.resetPropertyBinding(((DataSetEditor)getContainer()).getHandle(),dataSetMap,dataSourceMap);
    }
  }
 else {
    context=new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION,((DataSetEditor)getContainer()).getHandle().getModuleHandle());
    DataRequestSession session=DataRequestSession.newSession(context);
    try {
      DataSetViewData[] viewDatas=DataSetProvider.getCurrentInstance().populateAllOutputColumns(((DataSetEditor)getContainer()).getHandle(),session);
      if (viewDatas == null) {
        viewDatas=((DataSetEditor)getContainer()).getCurrentItemModel(false,false);
      }
      updateDefaultPropertyValues(viewDatas);
      if (isNewlyCreated) {
        updateAnalysisTypes(viewDatas,true);
      }
      viewer.getViewer().setInput(viewDatas);
    }
  finally {
      session.shutdown();
    }
  }
  Thread.currentThread().setContextClassLoader(oldContextLoader);
}

Fixed version (ground truth):
/** 
 * populate output columns
 * @throws BirtException
 */
protected void populateOutputColums() throws BirtException {
  ClassLoader oldContextLoader=Thread.currentThread().getContextClassLoader();
  ClassLoader parentLoader=oldContextLoader;
  if (parentLoader == null)   parentLoader=this.getClass().getClassLoader();
  ClassLoader newContextLoader=DataSetProvider.getCustomScriptClassLoader(parentLoader,((DataSetEditor)getContainer()).getHandle().getModuleHandle());
  ModuleHandle handle=((DataSetEditor)getContainer()).getHandle().getModuleHandle();
  DataSessionContext context;
  if (handle instanceof ReportDesignHandle) {
    Map dataSetMap=new HashMap();
    Map dataSourceMap=new HashMap();
    DummyEngineTask engineTask=null;
    DataRequestSession session=null;
    ReportEngine engine=null;
    try {
      EngineConfig ec=new EngineConfig();
      ec.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,newContextLoader);
      engine=(ReportEngine)new ReportEngineFactory().createReportEngine(ec);
      DataSetMetaDataHelper.clearPropertyBindingMap(((DataSetEditor)getContainer()).getHandle(),dataSetMap,dataSourceMap);
      ReportDesignHandle copy=(ReportDesignHandle)(handle.copy().getHandle(null));
      engineTask=new DummyEngineTask(engine,new ReportEngineHelper(engine).openReportDesign((ReportDesignHandle)copy),copy);
      session=engineTask.getDataSession();
      engineTask.run();
      DataSetViewData[] viewDatas=DataSetProvider.getCurrentInstance().populateAllOutputColumns(((DataSetEditor)getContainer()).getHandle(),session);
      if (viewDatas == null) {
        viewDatas=((DataSetEditor)getContainer()).getCurrentItemModel(false,false);
      }
      updateDefaultAnalysisEnablement(viewDatas);
      if (isNewlyCreated) {
        updateDefaultPropertyValues(viewDatas);
      }
      if (((DataSetEditor)getContainer()).getHandle() instanceof JointDataSetHandle) {
        PropertyHandle properyHandle=((DataSetEditor)getContainer()).getHandle().getPropertyHandle(DataSetHandle.COLUMN_HINTS_PROP);
        if (properyHandle != null) {
          for (int i=0; i < viewDatas.length; i++) {
            for (Iterator columns=properyHandle.iterator(); columns.hasNext(); ) {
              ColumnHintHandle column=(ColumnHintHandle)columns.next();
              if (viewDatas[i].getName().equals(column.getColumnName())) {
                viewDatas[i].setAlias(column.getAlias());
                break;
              }
            }
          }
        }
      }
      viewer.getViewer().setInput(viewDatas);
    }
  finally {
      session.shutdown();
      engineTask.close();
      engine.destroy();
      DataSetMetaDataHelper.resetPropertyBinding(((DataSetEditor)getContainer()).getHandle(),dataSetMap,dataSourceMap);
    }
  }
 else {
    context=new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION,((DataSetEditor)getContainer()).getHandle().getModuleHandle());
    DataRequestSession session=DataRequestSession.newSession(context);
    try {
      DataSetViewData[] viewDatas=DataSetProvider.getCurrentInstance().populateAllOutputColumns(((DataSetEditor)getContainer()).getHandle(),session);
      if (viewDatas == null) {
        viewDatas=((DataSetEditor)getContainer()).getCurrentItemModel(false,false);
      }
      updateDefaultAnalysisEnablement(viewDatas);
      if (isNewlyCreated) {
        updateDefaultPropertyValues(viewDatas);
      }
      viewer.getViewer().setInput(viewDatas);
    }
  finally {
      session.shutdown();
    }
  }
  Thread.currentThread().setContextClassLoader(oldContextLoader);
}