Program: 76353
Project: 76353
Buggy source:
/** 
 * runs the report
 * @throws EngineException throws exception when there is a run error
 */
protected void doRun() throws EngineException {
  if (!validateParameters()) {
    throw new EngineException(MessageConstants.INVALID_PARAMETER_EXCEPTION);
  }
  setupRenderOption();
  loadDesign();
  prepareDesign();
  startFactory();
  openReportDocument();
  try {
    ReportRunnable report=executionContext.getRunnable();
    writer.saveDesign(report);
    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();
      ReportExecutor executor=new ReportExecutor(executionContext,report.getReportIR(),emitter);
      executionContext.setExecutor(executor);
      initializeContentEmitter(emitter,executor);
      documentBuilder.build();
    }
    executionContext.closeDataEngine();
    writer.savePersistentObjects(executionContext.getGlobalBeans());
  }
 catch (  Exception ex) {
    log.log(Level.SEVERE,"String_Node_Str",ex);
    throw new EngineException("String_Node_Str",ex);
  }
catch (  OutOfMemoryError err) {
    log.log(Level.SEVERE,"String_Node_Str");
    throw err;
  }
catch (  Throwable t) {
    log.log(Level.SEVERE,"String_Node_Str",t);
    throw new EngineException("String_Node_Str",t);
  }
 finally {
    documentBuilder=null;
    closeReportDocument();
    closeFactory();
  }
}

Fixed version (ground truth):
/** 
 * runs the report
 * @throws EngineException throws exception when there is a run error
 */
protected void doRun() throws EngineException {
  if (!validateParameters()) {
    throw new EngineException(MessageConstants.INVALID_PARAMETER_EXCEPTION);
  }
  loadDesign();
  prepareDesign();
  startFactory();
  openReportDocument();
  try {
    ReportRunnable report=executionContext.getRunnable();
    writer.saveDesign(report);
    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();
      ReportExecutor executor=new ReportExecutor(executionContext,report.getReportIR(),emitter);
      executionContext.setExecutor(executor);
      initializeContentEmitter(emitter,executor);
      documentBuilder.build();
    }
    executionContext.closeDataEngine();
    writer.savePersistentObjects(executionContext.getGlobalBeans());
  }
 catch (  Exception ex) {
    log.log(Level.SEVERE,"String_Node_Str",ex);
    throw new EngineException("String_Node_Str",ex);
  }
catch (  OutOfMemoryError err) {
    log.log(Level.SEVERE,"String_Node_Str");
    throw err;
  }
catch (  Throwable t) {
    log.log(Level.SEVERE,"String_Node_Str",t);
    throw new EngineException("String_Node_Str",t);
  }
 finally {
    documentBuilder=null;
    closeReportDocument();
    closeFactory();
  }
}