Program: 70877
Project: 70877
Buggy source:
/** 
 * Creates a new render task and configure it.
 * @param out output stream
 * @param reportDocument report document
 * @param inputOptions input options
 * @param pageNumber page number
 * @param activeIds active IDs
 * @return configured render task
 * @throws ViewingSessionExpiredException 
 */
private IRenderTask createRenderTask(OutputStream out,IReportDocument reportDocument,InputOptions inputOptions,long pageNumber,List activeIds) throws ReportServiceException {
  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);
  String iServletPath=(String)inputOptions.getOption(InputOptions.OPT_SERVLET_PATH);
  boolean rtl=isRtl(inputOptions);
  boolean isDesigner=isDesigner(inputOptions);
  int pageOverflow=getPageOverflow(inputOptions);
  if (reportDocument == null) {
    throw new ReportServiceException(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_NO_REPORT_DOCUMENT));
  }
  String servletPath=iServletPath;
  if (servletPath == null)   servletPath=request.getServletPath();
  IRenderTask renderTask=engine.createRenderTask(reportDocument);
  BirtUtility.addTask(request,renderTask);
  Map context=BirtUtility.getAppContext(request);
  renderTask.setAppContext(context);
  RenderOption renderOption=null;
  if (format == null)   format=ParameterAccessor.getFormat(request);
  if (ParameterAccessor.isPDFLayout(format)) {
    renderOption=createPDFRenderOption(servletPath,request,pageOverflow,ParameterAccessor.isDesigner());
  }
 else {
    if (!IBirtConstants.HTML_RENDER_FORMAT.equalsIgnoreCase(format))     svgFlag=false;
    IViewingSession session=ViewingSessionUtil.getSession(request);
    if (session == null) {
      throw new IllegalStateException(BirtResources.getMessage(ResourceConstants.GENERAL_ERROR_NO_VIEWING_SESSION));
    }
    renderOption=createHTMLRenderOption(svgFlag,servletPath,request,session);
  }
  if (!IBirtConstants.EXCEL_RENDER_FORMAT.equalsIgnoreCase(format)) {
    ((IRenderOption)renderOption).setOption(IRenderOption.HTML_PAGINATION,Boolean.TRUE);
  }
  renderOption.setOutputStream(out);
  renderOption.setOutputFormat(format);
  renderOption.setEmitterID(emitterId);
  ViewerHTMLActionHandler handler=null;
  if (ParameterAccessor.isPDFLayout(format)) {
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,timeZone,false,rtl,masterPage,format,new Boolean(svgFlag),Boolean.toString(isDesigner));
  }
 else {
    boolean isEmbeddable=false;
    if (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(servletPath) || IBirtConstants.SERVLET_PATH_RUN.equalsIgnoreCase(servletPath))     isEmbeddable=true;
    if (renderOption instanceof IHTMLRenderOption)     ((IHTMLRenderOption)renderOption).setEmbeddable(isEmbeddable);
    renderOption.setOption(IHTMLRenderOption.INSTANCE_ID_LIST,activeIds);
    renderOption.setOption(IHTMLRenderOption.MASTER_PAGE_CONTENT,new Boolean(masterPage));
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,timeZone,isEmbeddable,rtl,masterPage,format,new Boolean(svgFlag),Boolean.toString(isDesigner));
    IViewingSession session=ViewingSessionUtil.getSession(request);
    if (session == null) {
      throw new ReportServiceException(BirtResources.getMessage(ResourceConstants.GENERAL_ERROR_NO_VIEWING_SESSION));
    }
    handler.setViewingSessionId(session.getId());
  }
  handler.setPageOverflow(Integer.toString(pageOverflow));
  String resourceFolder=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_RESOURCE_FOLDER);
  handler.setResourceFolder(resourceFolder);
  renderOption.setActionHandler(handler);
  if (pageNumber >= 0) {
    initializeEmitterConfigs(request,renderOption.getOptions());
  }
  String reportTitle=ParameterAccessor.htmlDecode(ParameterAccessor.getTitle(request));
  if (reportTitle != null)   renderOption.setOption(IHTMLRenderOption.HTML_TITLE,reportTitle);
  renderTask.setRenderOption(renderOption);
  renderTask.setLocale(locale);
  renderTask.setTimeZone(BirtUtility.toICUTimeZone(timeZone));
  return renderTask;
}

Fixed version (ground truth):
/** 
 * Creates a new render task and configure it.
 * @param out output stream
 * @param reportDocument report document
 * @param inputOptions input options
 * @param pageNumber page number
 * @param activeIds active IDs
 * @return configured render task
 * @throws ViewingSessionExpiredException 
 */
private IRenderTask createRenderTask(OutputStream out,IReportDocument reportDocument,InputOptions inputOptions,long pageNumber,List activeIds) throws ReportServiceException {
  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);
  String iServletPath=(String)inputOptions.getOption(InputOptions.OPT_SERVLET_PATH);
  boolean rtl=isRtl(inputOptions);
  boolean isDesigner=isDesigner(inputOptions);
  int pageOverflow=getPageOverflow(inputOptions);
  if (reportDocument == null) {
    throw new ReportServiceException(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_NO_REPORT_DOCUMENT));
  }
  String servletPath=iServletPath;
  if (servletPath == null)   servletPath=request.getServletPath();
  IRenderTask renderTask=engine.createRenderTask(reportDocument);
  BirtUtility.addTask(request,renderTask);
  Map context=BirtUtility.getAppContext(request);
  renderTask.setAppContext(context);
  RenderOption renderOption=null;
  if (format == null)   format=ParameterAccessor.getFormat(request);
  if (ParameterAccessor.isPDFLayout(format)) {
    renderOption=createPDFRenderOption(servletPath,request,pageOverflow,ParameterAccessor.isDesigner());
  }
 else {
    if (!IBirtConstants.HTML_RENDER_FORMAT.equalsIgnoreCase(format))     svgFlag=false;
    IViewingSession session=ViewingSessionUtil.getSession(request);
    if (session == null) {
      throw new IllegalStateException(BirtResources.getMessage(ResourceConstants.GENERAL_ERROR_NO_VIEWING_SESSION));
    }
    renderOption=createHTMLRenderOption(svgFlag,servletPath,request,session);
  }
  if (!IBirtConstants.EXCEL_RENDER_FORMAT.equalsIgnoreCase(format)) {
    ((IRenderOption)renderOption).setOption(IRenderOption.HTML_PAGINATION,Boolean.TRUE);
  }
  renderOption.setOutputStream(out);
  renderOption.setOutputFormat(format);
  renderOption.setEmitterID(emitterId);
  ViewerHTMLActionHandler handler=null;
  if (ParameterAccessor.isPDFLayout(format)) {
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,timeZone,false,rtl,masterPage,format,Boolean.valueOf(svgFlag),Boolean.toString(isDesigner));
  }
 else {
    boolean isEmbeddable=false;
    if (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(servletPath) || IBirtConstants.SERVLET_PATH_RUN.equalsIgnoreCase(servletPath))     isEmbeddable=true;
    if (renderOption instanceof IHTMLRenderOption)     ((IHTMLRenderOption)renderOption).setEmbeddable(isEmbeddable);
    renderOption.setOption(IHTMLRenderOption.INSTANCE_ID_LIST,activeIds);
    renderOption.setOption(IHTMLRenderOption.MASTER_PAGE_CONTENT,Boolean.valueOf(masterPage));
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,timeZone,isEmbeddable,rtl,masterPage,format,Boolean.valueOf(svgFlag),Boolean.toString(isDesigner));
    IViewingSession session=ViewingSessionUtil.getSession(request);
    if (session == null) {
      throw new ReportServiceException(BirtResources.getMessage(ResourceConstants.GENERAL_ERROR_NO_VIEWING_SESSION));
    }
    handler.setViewingSessionId(session.getId());
  }
  handler.setPageOverflow(Integer.toString(pageOverflow));
  String resourceFolder=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_RESOURCE_FOLDER);
  handler.setResourceFolder(resourceFolder);
  renderOption.setActionHandler(handler);
  if (pageNumber >= 0) {
    initializeEmitterConfigs(request,renderOption.getOptions());
  }
  String reportTitle=ParameterAccessor.htmlDecode(ParameterAccessor.getTitle(request));
  if (reportTitle != null)   renderOption.setOption(IHTMLRenderOption.HTML_TITLE,reportTitle);
  renderTask.setRenderOption(renderOption);
  renderTask.setLocale(locale);
  renderTask.setTimeZone(BirtUtility.toICUTimeZone(timeZone));
  return renderTask;
}