Program: 70876
Project: 70876
Buggy source:
private IRunAndRenderTask createRunAndRenderTask(IReportRunnable runnable,OutputStream outputStream,InputOptions inputOptions,Map parameters,Boolean embeddable,List activeIds,RenderOption aRenderOption,Map displayTexts,String reportTitle,Integer maxRows) throws ReportServiceException {
  RenderOption renderOption=aRenderOption;
  HttpServletRequest request=(HttpServletRequest)inputOptions.getOption(InputOptions.OPT_REQUEST);
  Locale locale=(Locale)inputOptions.getOption(InputOptions.OPT_LOCALE);
  TimeZone timeZone=(TimeZone)inputOptions.getOption(InputOptions.OPT_TIMEZONE);
  Boolean isMasterPageContent=(Boolean)inputOptions.getOption(InputOptions.OPT_IS_MASTER_PAGE_CONTENT);
  boolean masterPage=isMasterPageContent == null ? true : isMasterPageContent.booleanValue();
  Boolean svgFlag=(Boolean)inputOptions.getOption(InputOptions.OPT_SVG_FLAG);
  String format=(String)inputOptions.getOption(InputOptions.OPT_FORMAT);
  String emitterId=(String)inputOptions.getOption(InputOptions.OPT_EMITTER_ID);
  boolean rtl=isRtl(inputOptions);
  boolean isDesigner=isDesigner(inputOptions);
  int pageOverflow=getPageOverflow(inputOptions);
  String iServletPath=(String)inputOptions.getOption(InputOptions.OPT_SERVLET_PATH);
  String servletPath=iServletPath;
  if (servletPath == null)   servletPath=request.getServletPath();
  IRunAndRenderTask runAndRenderTask=engine.createRunAndRenderTask(runnable);
  runAndRenderTask.setLocale(locale);
  runAndRenderTask.setTimeZone(BirtUtility.toICUTimeZone(timeZone));
  if (parameters != null) {
    runAndRenderTask.setParameterValues(parameters);
  }
  if (displayTexts != null) {
    Iterator keys=displayTexts.keySet().iterator();
    while (keys.hasNext()) {
      String paramName=DataUtil.getString(keys.next());
      String displayText=DataUtil.getString(displayTexts.get(paramName));
      runAndRenderTask.setParameterDisplayText(paramName,displayText);
    }
  }
  if (maxRows != null)   runAndRenderTask.setMaxRowsPerQuery(maxRows.intValue());
  Map context=BirtUtility.getAppContext(request);
  runAndRenderTask.setAppContext(context);
  ViewerHTMLActionHandler handler=new ViewerHTMLActionHandler(locale,timeZone,rtl,masterPage,format,new Boolean(svgFlag),Boolean.toString(isDesigner));
  handler.setPageOverflow(Integer.toString(pageOverflow));
  String resourceFolder=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_RESOURCE_FOLDER);
  handler.setResourceFolder(resourceFolder);
  IViewingSession session=ViewingSessionUtil.getSession(request);
  if (!ParameterAccessor.isPDFLayout(format)) {
    if (session != null) {
      handler.setViewingSessionId(session.getId());
    }
 else {
      throw new IllegalStateException(BirtResources.getMessage(ResourceConstants.GENERAL_ERROR_NO_VIEWING_SESSION));
    }
  }
  if (renderOption == null) {
    if (ParameterAccessor.isPDFLayout(format)) {
      renderOption=createPDFRenderOption(servletPath,request,pageOverflow,isDesigner);
    }
 else {
      if (!IBirtConstants.HTML_RENDER_FORMAT.equalsIgnoreCase(format))       svgFlag=false;
      renderOption=createHTMLRenderOption(svgFlag,servletPath,request,session);
    }
  }
  renderOption.setOutputStream(outputStream);
  renderOption.setOutputFormat(format);
  renderOption.setEmitterID(emitterId);
  renderOption.setOption(IHTMLRenderOption.MASTER_PAGE_CONTENT,Boolean.valueOf(masterPage));
  renderOption.setActionHandler(handler);
  if (reportTitle != null)   renderOption.setOption(IHTMLRenderOption.HTML_TITLE,reportTitle);
  if (renderOption instanceof IHTMLRenderOption) {
    boolean isEmbeddable=false;
    if (embeddable != null)     isEmbeddable=embeddable.booleanValue();
    if (IBirtConstants.SERVLET_PATH_RUN.equalsIgnoreCase(servletPath))     isEmbeddable=true;
    ((IHTMLRenderOption)renderOption).setEmbeddable(isEmbeddable);
  }
  renderOption.setOption(IHTMLRenderOption.INSTANCE_ID_LIST,activeIds);
  initializeEmitterConfigs(request,renderOption.getOptions());
  runAndRenderTask.setRenderOption(renderOption);
  return runAndRenderTask;
}

Fixed version (ground truth):
private IRunAndRenderTask createRunAndRenderTask(IReportRunnable runnable,OutputStream outputStream,InputOptions inputOptions,Map parameters,Boolean embeddable,List activeIds,RenderOption aRenderOption,Map displayTexts,String reportTitle,Integer maxRows) throws ReportServiceException {
  RenderOption renderOption=aRenderOption;
  HttpServletRequest request=(HttpServletRequest)inputOptions.getOption(InputOptions.OPT_REQUEST);
  Locale locale=(Locale)inputOptions.getOption(InputOptions.OPT_LOCALE);
  TimeZone timeZone=(TimeZone)inputOptions.getOption(InputOptions.OPT_TIMEZONE);
  Boolean isMasterPageContent=(Boolean)inputOptions.getOption(InputOptions.OPT_IS_MASTER_PAGE_CONTENT);
  boolean masterPage=isMasterPageContent == null ? true : isMasterPageContent.booleanValue();
  Boolean svgFlag=(Boolean)inputOptions.getOption(InputOptions.OPT_SVG_FLAG);
  String format=(String)inputOptions.getOption(InputOptions.OPT_FORMAT);
  String emitterId=(String)inputOptions.getOption(InputOptions.OPT_EMITTER_ID);
  boolean rtl=isRtl(inputOptions);
  boolean isDesigner=isDesigner(inputOptions);
  int pageOverflow=getPageOverflow(inputOptions);
  String iServletPath=(String)inputOptions.getOption(InputOptions.OPT_SERVLET_PATH);
  String servletPath=iServletPath;
  if (servletPath == null)   servletPath=request.getServletPath();
  IRunAndRenderTask runAndRenderTask=engine.createRunAndRenderTask(runnable);
  runAndRenderTask.setLocale(locale);
  runAndRenderTask.setTimeZone(BirtUtility.toICUTimeZone(timeZone));
  if (parameters != null) {
    runAndRenderTask.setParameterValues(parameters);
  }
  if (displayTexts != null) {
    Iterator keys=displayTexts.keySet().iterator();
    while (keys.hasNext()) {
      String paramName=DataUtil.getString(keys.next());
      String displayText=DataUtil.getString(displayTexts.get(paramName));
      runAndRenderTask.setParameterDisplayText(paramName,displayText);
    }
  }
  if (maxRows != null)   runAndRenderTask.setMaxRowsPerQuery(maxRows.intValue());
  Map context=BirtUtility.getAppContext(request);
  runAndRenderTask.setAppContext(context);
  ViewerHTMLActionHandler handler=new ViewerHTMLActionHandler(locale,timeZone,rtl,masterPage,format,Boolean.valueOf(svgFlag),Boolean.toString(isDesigner));
  handler.setPageOverflow(Integer.toString(pageOverflow));
  String resourceFolder=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_RESOURCE_FOLDER);
  handler.setResourceFolder(resourceFolder);
  IViewingSession session=ViewingSessionUtil.getSession(request);
  if (!ParameterAccessor.isPDFLayout(format)) {
    if (session != null) {
      handler.setViewingSessionId(session.getId());
    }
 else {
      throw new IllegalStateException(BirtResources.getMessage(ResourceConstants.GENERAL_ERROR_NO_VIEWING_SESSION));
    }
  }
  if (renderOption == null) {
    if (ParameterAccessor.isPDFLayout(format)) {
      renderOption=createPDFRenderOption(servletPath,request,pageOverflow,isDesigner);
    }
 else {
      if (!IBirtConstants.HTML_RENDER_FORMAT.equalsIgnoreCase(format))       svgFlag=false;
      renderOption=createHTMLRenderOption(svgFlag,servletPath,request,session);
    }
  }
  renderOption.setOutputStream(outputStream);
  renderOption.setOutputFormat(format);
  renderOption.setEmitterID(emitterId);
  renderOption.setOption(IHTMLRenderOption.MASTER_PAGE_CONTENT,Boolean.valueOf(masterPage));
  renderOption.setActionHandler(handler);
  if (reportTitle != null)   renderOption.setOption(IHTMLRenderOption.HTML_TITLE,reportTitle);
  if (renderOption instanceof IHTMLRenderOption) {
    boolean isEmbeddable=false;
    if (embeddable != null)     isEmbeddable=embeddable.booleanValue();
    if (IBirtConstants.SERVLET_PATH_RUN.equalsIgnoreCase(servletPath))     isEmbeddable=true;
    ((IHTMLRenderOption)renderOption).setEmbeddable(isEmbeddable);
  }
  renderOption.setOption(IHTMLRenderOption.INSTANCE_ID_LIST,activeIds);
  initializeEmitterConfigs(request,renderOption.getOptions());
  runAndRenderTask.setRenderOption(renderOption);
  return runAndRenderTask;
}