Program: 76940
Project: 76940
Buggy source:
protected IViewerReportDesignHandle getDesignHandle(HttpServletRequest request){
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  boolean isValidDocument=ParameterAccessor.isValidFilePath(this.reportDocumentName);
  if (isValidDocument) {
    IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName,this.getModuleOptions(request));
    if (reportDocumentInstance != null) {
      reportRunnable=reportDocumentInstance.getReportRunnable();
      if (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath())) {
        this.parameterMap=reportDocumentInstance.getParameterValues();
      }
      if (ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT) != null)       this.documentInUrl=true;
      if (!reportDocumentInstance.isComplete() && ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT))       this.isDocumentProcessing=true;
      reportDocumentInstance.close();
    }
  }
  if (reportRunnable == null) {
    if (ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT_DOCUMENT) && !ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT)) {
      if (isValidDocument)       this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{this.reportDocumentName});
 else       this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{this.reportDocumentName});
      return design;
    }
    if (!ParameterAccessor.isValidFilePath(this.reportDesignName)) {
      this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_ACCESS_ERROR,new String[]{this.reportDesignName});
    }
 else {
      try {
        File file=new File(this.reportDesignName);
        if (file.exists()) {
          reportRunnable=ReportEngineService.getInstance().openReportDesign(this.reportDesignName,this.getModuleOptions(request));
        }
 else         if (!ParameterAccessor.isWorkingFolderAccessOnly()) {
          this.reportDesignName=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT);
          InputStream is=null;
          URL url=null;
          try {
            String reportPath=this.reportDesignName;
            if (!reportPath.startsWith("String_Node_Str"))             reportPath="String_Node_Str" + reportPath;
            url=request.getSession().getServletContext().getResource(reportPath);
            if (url != null)             is=url.openStream();
            if (is != null)             reportRunnable=ReportEngineService.getInstance().openReportDesign(url.toString(),is,this.getModuleOptions(request));
          }
 catch (          Exception e) {
          }
        }
        if (reportRunnable == null) {
          this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{this.reportDesignName});
        }
      }
 catch (      EngineException e) {
        this.exception=e;
      }
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}

Fixed version (ground truth):
protected IViewerReportDesignHandle getDesignHandle(HttpServletRequest request){
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  boolean isValidDocument=ParameterAccessor.isValidFilePath(this.reportDocumentName);
  if (isValidDocument) {
    IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName,this.getModuleOptions(request));
    if (reportDocumentInstance != null) {
      reportRunnable=reportDocumentInstance.getReportRunnable();
      if (ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT) != null)       this.documentInUrl=true;
      if (IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase(request.getServletPath()) || this.documentInUrl) {
        this.parameterMap=reportDocumentInstance.getParameterValues();
      }
      if (!reportDocumentInstance.isComplete() && ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT))       this.isDocumentProcessing=true;
      reportDocumentInstance.close();
    }
  }
  if (reportRunnable == null) {
    if (ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT_DOCUMENT) && !ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT)) {
      if (isValidDocument)       this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{this.reportDocumentName});
 else       this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{this.reportDocumentName});
      return design;
    }
    if (!ParameterAccessor.isValidFilePath(this.reportDesignName)) {
      this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_ACCESS_ERROR,new String[]{this.reportDesignName});
    }
 else {
      try {
        File file=new File(this.reportDesignName);
        if (file.exists()) {
          reportRunnable=ReportEngineService.getInstance().openReportDesign(this.reportDesignName,this.getModuleOptions(request));
        }
 else         if (!ParameterAccessor.isWorkingFolderAccessOnly()) {
          this.reportDesignName=ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT);
          InputStream is=null;
          URL url=null;
          try {
            String reportPath=this.reportDesignName;
            if (!reportPath.startsWith("String_Node_Str"))             reportPath="String_Node_Str" + reportPath;
            url=request.getSession().getServletContext().getResource(reportPath);
            if (url != null)             is=url.openStream();
            if (is != null)             reportRunnable=ReportEngineService.getInstance().openReportDesign(url.toString(),is,this.getModuleOptions(request));
          }
 catch (          Exception e) {
          }
        }
        if (reportRunnable == null) {
          this.exception=new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{this.reportDesignName});
        }
      }
 catch (      EngineException e) {
        this.exception=e;
      }
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}