Program: 65905
Project: 65905
Buggy source:
/** 
 * runs the report
 * @throws EngineException throws exception when there is a run error
 */
protected void doRun() throws EngineException {
  if (progressMonitor != null) {
    progressMonitor.onProgress(IProgressMonitor.START_TASK,TASK_RUN);
  }
  loadDataSource();
  doValidateParameters();
  ReportDesignHandle design=executionContext.getReportDesign();
  if (DesignChoiceConstants.REPORT_LAYOUT_PREFERENCE_FIXED_LAYOUT.equals(design.getLayoutPreference())) {
    executionContext.setFixedLayout(true);
    setupRenderOption();
    updateRtLFlag();
  }
  initReportVariable();
  loadDesign();
  prepareDesign();
  startFactory();
  openReportDocument();
  ArrayList<String> errList=new ArrayList<String>();
  RunStatusWriter statusWriter=null;
  try {
    statusWriter=new RunStatusWriter(archiveWriter);
    ReportRunnable newRunnable=writer.saveDesign(executionContext.getRunnable(),executionContext.getOriginalRunnable());
    executionContext.updateRunnable(newRunnable);
    writer.saveReportIR(executionContext.getReport());
    writer.saveParamters(inputValues);
    executionContext.openDataEngine();
synchronized (this) {
      if (!executionContext.isCanceled()) {
        documentBuilder=new ReportDocumentBuilder(executionContext,writer);
      }
    }
    if (documentBuilder != null) {
      if (pageHandler != null) {
        documentBuilder.setPageHandler(pageHandler);
      }
      IContentEmitter emitter=documentBuilder.getContentEmitter();
      IReportExecutor executor=new ReportExecutor(executionContext);
      executor=createReportExtensionExecutor(executor);
      executor=new ReportEmitterExecutor(executor,emitter);
      executor=new SuppressDuplciateReportExecutor(executor);
      if (executionContext.isFixedLayout()) {
        executor=new LocalizedReportExecutor(executionContext,executor);
      }
      executionContext.setExecutor(executor);
      initializeContentEmitter(emitter);
      documentBuilder.build();
    }
    executionContext.closeDataEngine();
  }
 catch (  Throwable t) {
    errList.add(t.getLocalizedMessage());
    handleFatalExceptions(t);
  }
 finally {
    documentBuilder=null;
    closeFactory();
    List<Exception> list=(List<Exception>)executionContext.getAllErrors();
    if (list != null) {
      for (      Exception ex : list) {
        errList.add(ex.getLocalizedMessage());
      }
    }
    if (statusWriter != null && !errList.isEmpty()) {
      statusWriter.writeRunTaskStatus(errList);
    }
    writer.savePersistentObjects(executionContext.getGlobalBeans());
    writer.finish();
    if (pageHandler != null && !executionContext.isCanceled()) {
      int totalPage=(int)executionContext.getTotalPage();
      IReportDocumentInfo docInfo=new ReportDocumentInfo(executionContext,totalPage,true);
      pageHandler.onPage(totalPage,true,docInfo);
    }
    if (progressMonitor != null) {
      progressMonitor.onProgress(IProgressMonitor.END_TASK,TASK_RUN);
    }
    closeReportDocument();
  }
}

Fixed version (ground truth):
/** 
 * runs the report
 * @throws EngineException throws exception when there is a run error
 */
protected void doRun() throws EngineException {
  if (progressMonitor != null) {
    progressMonitor.onProgress(IProgressMonitor.START_TASK,TASK_RUN);
  }
  loadDataSource();
  doValidateParameters();
  ReportDesignHandle design=executionContext.getReportDesign();
  if (DesignChoiceConstants.REPORT_LAYOUT_PREFERENCE_FIXED_LAYOUT.equals(design.getLayoutPreference())) {
    executionContext.setFixedLayout(true);
    setupRenderOption();
    updateRtLFlag();
  }
  initReportVariable();
  loadDesign();
  prepareDesign();
  startFactory();
  openReportDocument();
  ArrayList<String> errList=new ArrayList<String>();
  try {
    ReportRunnable newRunnable=writer.saveDesign(executionContext.getRunnable(),executionContext.getOriginalRunnable());
    executionContext.updateRunnable(newRunnable);
    writer.saveReportIR(executionContext.getReport());
    writer.saveParamters(inputValues);
    executionContext.openDataEngine();
synchronized (this) {
      if (!executionContext.isCanceled()) {
        documentBuilder=new ReportDocumentBuilder(executionContext,writer);
      }
    }
    if (documentBuilder != null) {
      if (pageHandler != null) {
        documentBuilder.setPageHandler(pageHandler);
      }
      IContentEmitter emitter=documentBuilder.getContentEmitter();
      IReportExecutor executor=new ReportExecutor(executionContext);
      executor=createReportExtensionExecutor(executor);
      executor=new ReportEmitterExecutor(executor,emitter);
      executor=new SuppressDuplciateReportExecutor(executor);
      if (executionContext.isFixedLayout()) {
        executor=new LocalizedReportExecutor(executionContext,executor);
      }
      executionContext.setExecutor(executor);
      initializeContentEmitter(emitter);
      documentBuilder.build();
    }
    executionContext.closeDataEngine();
  }
 catch (  Throwable t) {
    errList.add(t.getLocalizedMessage());
    handleFatalExceptions(t);
  }
 finally {
    documentBuilder=null;
    closeFactory();
    List<Exception> list=(List<Exception>)executionContext.getAllErrors();
    if (list != null) {
      for (      Exception ex : list) {
        errList.add(ex.getLocalizedMessage());
      }
    }
    if (!errList.isEmpty()) {
      RunStatusWriter statusWriter=new RunStatusWriter(archiveWriter);
      statusWriter.writeRunTaskStatus(errList);
      statusWriter.close();
    }
    writer.savePersistentObjects(executionContext.getGlobalBeans());
    writer.finish();
    if (pageHandler != null && !executionContext.isCanceled()) {
      int totalPage=(int)executionContext.getTotalPage();
      IReportDocumentInfo docInfo=new ReportDocumentInfo(executionContext,totalPage,true);
      pageHandler.onPage(totalPage,true,docInfo);
    }
    if (progressMonitor != null) {
      progressMonitor.onProgress(IProgressMonitor.END_TASK,TASK_RUN);
    }
    closeReportDocument();
  }
}