Program: 72695
Project: 72695
Buggy source:
/** 
 * Render report page.
 * @param out
 * @param request
 * @param reportDocument
 * @param format
 * @param pageNumber
 * @param pageRange
 * @param masterPage
 * @param svgFlag
 * @param activeIds
 * @param locale
 * @param rtl
 * @param iServletPath
 * @throws RemoteException
 */
public void renderReport(OutputStream out,HttpServletRequest request,IReportDocument reportDocument,String format,long pageNumber,String pageRange,boolean masterPage,boolean svgFlag,List activeIds,Locale locale,boolean rtl,String iServletPath) throws RemoteException {
  if (reportDocument == null) {
    AxisFault fault=new AxisFault(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_NO_REPORT_DOCUMENT));
    fault.setFaultCode(new QName("String_Node_Str"));
    throw fault;
  }
  if (out == null)   return;
  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,ParameterAccessor.isDesigner(request));
  }
 else {
    if (!IBirtConstants.HTML_RENDER_FORMAT.equalsIgnoreCase(format))     svgFlag=false;
    renderOption=createHTMLRenderOption(svgFlag,servletPath,request);
  }
  if (!IBirtConstants.EXCEL_RENDER_FORMAT.equalsIgnoreCase(format)) {
    ((IRenderOption)renderOption).setOption(IRenderOption.HTML_PAGINATION,Boolean.TRUE);
  }
  renderOption.setOutputStream(out);
  renderOption.setOutputFormat(format);
  ViewerHTMLActionHandler handler=null;
  if (ParameterAccessor.isPDFLayout(format)) {
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,false,rtl,masterPage,format,new Boolean(svgFlag),ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_DESIGNER));
  }
 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.HTML_RTL_FLAG,new Boolean(rtl));
    renderOption.setOption(IHTMLRenderOption.INSTANCE_ID_LIST,activeIds);
    renderOption.setOption(IHTMLRenderOption.MASTER_PAGE_CONTENT,new Boolean(masterPage));
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,isEmbeddable,rtl,masterPage,format,new Boolean(svgFlag),ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_DESIGNER));
  }
  String resourceFolder=ParameterAccessor.getResourceFolder(request);
  handler.setResourceFolder(resourceFolder);
  renderOption.setActionHandler(handler);
  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);
  try {
    if (pageNumber > 0)     renderTask.setPageNumber(pageNumber);
    if (pageRange != null) {
      if (!IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(servletPath) || !ParameterAccessor.PARAM_FORMAT_HTML.equalsIgnoreCase(format))       renderTask.setPageRange(pageRange);
    }
    renderTask.render();
  }
 catch (  Exception e) {
    AxisFault fault=new AxisFault(e.getLocalizedMessage(),e.getCause());
    fault.setFaultCode(new QName("String_Node_Str"));
    throw fault;
  }
 finally {
    BirtUtility.removeTask(request);
    if (ParameterAccessor.isDesigner(request))     BirtUtility.error(request,renderTask.getErrors());
    renderTask.close();
  }
}

Fixed version (ground truth):
/** 
 * Render report page.
 * @param out
 * @param request
 * @param reportDocument
 * @param format
 * @param pageNumber
 * @param pageRange
 * @param masterPage
 * @param svgFlag
 * @param activeIds
 * @param locale
 * @param rtl
 * @param iServletPath
 * @throws RemoteException
 */
public void renderReport(OutputStream out,HttpServletRequest request,IReportDocument reportDocument,String format,long pageNumber,String pageRange,boolean masterPage,boolean svgFlag,List activeIds,Locale locale,boolean rtl,String iServletPath) throws RemoteException {
  if (reportDocument == null) {
    AxisFault fault=new AxisFault(BirtResources.getMessage(ResourceConstants.ACTION_EXCEPTION_NO_REPORT_DOCUMENT));
    fault.setFaultCode(new QName("String_Node_Str"));
    throw fault;
  }
  if (out == null)   return;
  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,ParameterAccessor.isDesigner());
  }
 else {
    if (!IBirtConstants.HTML_RENDER_FORMAT.equalsIgnoreCase(format))     svgFlag=false;
    renderOption=createHTMLRenderOption(svgFlag,servletPath,request);
  }
  if (!IBirtConstants.EXCEL_RENDER_FORMAT.equalsIgnoreCase(format)) {
    ((IRenderOption)renderOption).setOption(IRenderOption.HTML_PAGINATION,Boolean.TRUE);
  }
  renderOption.setOutputStream(out);
  renderOption.setOutputFormat(format);
  ViewerHTMLActionHandler handler=null;
  if (ParameterAccessor.isPDFLayout(format)) {
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,false,rtl,masterPage,format,new Boolean(svgFlag),ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_DESIGNER));
  }
 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.HTML_RTL_FLAG,new Boolean(rtl));
    renderOption.setOption(IHTMLRenderOption.INSTANCE_ID_LIST,activeIds);
    renderOption.setOption(IHTMLRenderOption.MASTER_PAGE_CONTENT,new Boolean(masterPage));
    handler=new ViewerHTMLActionHandler(reportDocument,pageNumber,locale,isEmbeddable,rtl,masterPage,format,new Boolean(svgFlag),ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_DESIGNER));
  }
  if (ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_RESOURCE_FOLDER)) {
    String resourceFolder=ParameterAccessor.getResourceFolder(request);
    handler.setResourceFolder(resourceFolder);
  }
  renderOption.setActionHandler(handler);
  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);
  try {
    if (pageNumber > 0)     renderTask.setPageNumber(pageNumber);
    if (pageRange != null) {
      if (!IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(servletPath) || !ParameterAccessor.PARAM_FORMAT_HTML.equalsIgnoreCase(format))       renderTask.setPageRange(pageRange);
    }
    renderTask.render();
  }
 catch (  Exception e) {
    AxisFault fault=new AxisFault(e.getLocalizedMessage(),e.getCause());
    fault.setFaultCode(new QName("String_Node_Str"));
    throw fault;
  }
 finally {
    BirtUtility.removeTask(request);
    if (ParameterAccessor.isDesigner())     BirtUtility.error(request,renderTask.getErrors());
    renderTask.close();
  }
}