Program: 76266
Project: 76266
Buggy source:
/** 
 * Render the report in html/pdf format by calling engine service.
 * @param request incoming http request
 * @param response http response
 * @exception ServletException
 * @exception IOException
 */
protected void doService(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  BaseAttributeBean attrBean=(BaseAttributeBean)request.getAttribute(IBirtConstants.ATTRIBUTE_BEAN);
  OutputStream out=response.getOutputStream();
  GetUpdatedObjectsResponse upResponse=new GetUpdatedObjectsResponse();
  IContext context=new BirtContext(request,response);
  Operation op=null;
  try {
    if (IBirtConstants.SERVLET_PATH_DOWNLOAD.equalsIgnoreCase(request.getServletPath())) {
      BirtExtractDataActionHandler extractDataHandler=new BirtExtractDataActionHandler(context,op,upResponse);
      extractDataHandler.execute();
    }
 else     if (ParameterAccessor.isGetImageOperator(request)) {
      BirtRenderImageActionHandler renderImageHandler=new BirtRenderImageActionHandler(context,op,upResponse);
      renderImageHandler.execute();
    }
 else {
      boolean isPrint=false;
      if (IBirtConstants.ACTION_PRINT.equalsIgnoreCase(attrBean.getAction())) {
        isPrint=true;
        out=new ByteArrayOutputStream();
      }
      if (ParameterAccessor.isGetReportlet(request)) {
        BirtGetReportletActionHandler getReportletHandler=new BirtGetReportletActionHandler(context,op,upResponse,out);
        getReportletHandler.execute();
      }
 else       if (context.getBean().documentInUrl) {
        BirtRenderReportActionHandler runReportHandler=new BirtRenderReportActionHandler(context,op,upResponse,out);
        runReportHandler.execute();
      }
 else {
        BirtRunAndRenderActionHandler runAndRenderHandler=new BirtRunAndRenderActionHandler(context,op,upResponse,out);
        runAndRenderHandler.execute();
      }
      if (isPrint) {
        InputStream inputStream=new ByteArrayInputStream(out.toString().getBytes());
        BirtUtility.doPrintAction(inputStream,request,response);
      }
    }
  }
 catch (  RemoteException e) {
    if (!ParameterAccessor.isGetImageOperator(request)) {
      AxisFault fault=(AxisFault)e;
      response.setContentType("String_Node_Str");
      BirtUtility.writeMessage(response.getOutputStream(),ParameterAccessor.htmlEncode(fault.getFaultString()),IBirtConstants.MSG_ERROR);
    }
  }
}

Fixed version (ground truth):
/** 
 * Render the report in html/pdf format by calling engine service.
 * @param request incoming http request
 * @param response http response
 * @exception ServletException
 * @exception IOException
 */
protected void doService(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  BaseAttributeBean attrBean=(BaseAttributeBean)request.getAttribute(IBirtConstants.ATTRIBUTE_BEAN);
  OutputStream out=response.getOutputStream();
  GetUpdatedObjectsResponse upResponse=new GetUpdatedObjectsResponse();
  IContext context=new BirtContext(request,response);
  Operation op=null;
  try {
    if (IBirtConstants.SERVLET_PATH_DOWNLOAD.equalsIgnoreCase(request.getServletPath())) {
      BirtExtractDataActionHandler extractDataHandler=new BirtExtractDataActionHandler(context,op,upResponse);
      extractDataHandler.execute();
    }
 else     if (ParameterAccessor.isGetImageOperator(request)) {
      BirtRenderImageActionHandler renderImageHandler=new BirtRenderImageActionHandler(context,op,upResponse);
      renderImageHandler.execute();
    }
 else {
      boolean isPrint=false;
      if (IBirtConstants.ACTION_PRINT.equalsIgnoreCase(attrBean.getAction())) {
        isPrint=true;
        out=new ByteArrayOutputStream();
      }
      if (ParameterAccessor.isGetReportlet(request)) {
        BirtGetReportletActionHandler getReportletHandler=new BirtGetReportletActionHandler(context,op,upResponse,out);
        getReportletHandler.execute();
      }
 else       if (context.getBean().documentInUrl) {
        BirtRenderReportActionHandler runReportHandler=new BirtRenderReportActionHandler(context,op,upResponse,out);
        runReportHandler.execute();
      }
 else {
        BirtRunAndRenderActionHandler runAndRenderHandler=new BirtRunAndRenderActionHandler(context,op,upResponse,out);
        runAndRenderHandler.execute();
      }
      if (isPrint) {
        InputStream inputStream=new ByteArrayInputStream(((ByteArrayOutputStream)out).toByteArray());
        BirtUtility.doPrintAction(inputStream,request,response);
      }
    }
  }
 catch (  RemoteException e) {
    if (!ParameterAccessor.isGetImageOperator(request)) {
      response.setContentType("String_Node_Str");
      BirtUtility.appendErrorMessage(response.getOutputStream(),e);
    }
  }
}