Program: 65272
Project: 65272
Buggy source:
/** 
 * Returns the report design handle
 * @param request
 * @throws Exception
 * @return Report Design Handle
 */
protected IViewerReportDesignHandle getDesignHandle(HttpServletRequest request) throws Exception {
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  IReportDocument reportDocumentInstance=null;
  boolean isDocumentExist=ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT_DOCUMENT);
  boolean isReportExist=ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT);
  if (isDocumentExist && !isReportExist) {
    boolean isValidDocument=ParameterAccessor.isValidFilePath(request,ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT));
    if (isValidDocument) {
      try {
        reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName,this.moduleOptions);
      }
 catch (      Exception e) {
      }
      if (reportDocumentInstance != null) {
        reportRunnable=reportDocumentInstance.getReportRunnable();
      }
 else {
        throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{this.reportDocumentName});
      }
    }
 else {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{this.reportDocumentName});
    }
  }
 else   if (isReportExist) {
    if (isDocumentExist && !ParameterAccessor.isValidFilePath(request,ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT))) {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{this.reportDocumentName});
    }
    try {
      reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName,this.moduleOptions);
    }
 catch (    Exception e) {
    }
    if (ParameterAccessor.isValidFilePath(request,ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT))) {
      try {
        reportRunnable=BirtUtility.getRunnableFromDesignFile(request,this.reportDesignName,this.moduleOptions);
        if (reportRunnable == null) {
          throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{this.reportDesignName});
        }
      }
 catch (      EngineException e) {
        this.exception=e;
      }
    }
  }
  if (reportDocumentInstance != null) {
    this.documentInUrl=true;
    this.parameterMap=reportDocumentInstance.getParameterValues();
    if (!reportDocumentInstance.isComplete() && isReportExist)     this.isDocumentProcessing=true;
    reportDocumentInstance.close();
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}

Fixed version (ground truth):
/** 
 * Returns the report design handle
 * @param request
 * @throws Exception
 * @return Report Design Handle
 */
protected IViewerReportDesignHandle getDesignHandle(HttpServletRequest request) throws Exception {
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  IReportDocument reportDocumentInstance=null;
  boolean isDocumentExist=ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT_DOCUMENT);
  boolean isReportExist=ParameterAccessor.isReportParameterExist(request,ParameterAccessor.PARAM_REPORT);
  if (isDocumentExist && !isReportExist) {
    boolean isValidDocument=ParameterAccessor.isValidFilePath(request,ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT));
    if (isValidDocument) {
      try {
        reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName,this.moduleOptions);
      }
 catch (      Exception e) {
      }
      if (reportDocumentInstance != null) {
        reportRunnable=reportDocumentInstance.getReportRunnable();
      }
 else {
        throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{this.reportDocumentName});
      }
    }
 else {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{this.reportDocumentName});
    }
  }
 else   if (isReportExist) {
    if (isDocumentExist && !ParameterAccessor.isValidFilePath(request,ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT_DOCUMENT))) {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{this.reportDocumentName});
    }
    try {
      reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(this.reportDesignName,this.reportDocumentName,this.moduleOptions);
    }
 catch (    Exception e) {
    }
    if (ParameterAccessor.isValidFilePath(request,ParameterAccessor.getParameter(request,ParameterAccessor.PARAM_REPORT))) {
      try {
        reportRunnable=BirtUtility.getRunnableFromDesignFile(request,this.reportDesignName,this.moduleOptions);
        if (reportRunnable == null) {
          throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{new File(this.reportDesignName).getName()});
        }
      }
 catch (      EngineException e) {
        this.exception=e;
      }
    }
  }
  if (reportDocumentInstance != null) {
    this.documentInUrl=true;
    this.parameterMap=reportDocumentInstance.getParameterValues();
    if (!reportDocumentInstance.isComplete() && isReportExist)     this.isDocumentProcessing=true;
    reportDocumentInstance.close();
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}