Program: 72810
Project: 72810
Buggy source:
/** 
 * Returns report design handle
 * @param request
 * @param viewer
 * @return
 * @throws Exception
 */
public static IViewerReportDesignHandle getDesignHandle(HttpServletRequest request,ViewerField viewer) throws Exception {
  if (viewer == null)   return null;
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  String designFile=ParameterAccessor.getReport(request,viewer.getReportDesign());
  String documentFile=ParameterAccessor.getReportDocument(request,viewer.getReportDocument(),false);
  boolean isValidDocument=ParameterAccessor.isValidFilePath(viewer.getReportDocument());
  if (documentFile != null && isValidDocument) {
    IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(designFile,documentFile,getModuleOptions(viewer));
    if (reportDocumentInstance != null) {
      viewer.setDocumentInUrl(true);
      reportRunnable=reportDocumentInstance.getReportRunnable();
      reportDocumentInstance.close();
    }
  }
  if (reportRunnable == null) {
    if (documentFile != null && designFile == null) {
      if (isValidDocument)       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{documentFile});
 else       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{documentFile});
    }
    if (!ParameterAccessor.isValidFilePath(viewer.getReportDesign())) {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_ACCESS_ERROR,new String[]{designFile});
    }
 else {
      reportRunnable=BirtUtility.getRunnableFromDesignFile(request,designFile,getModuleOptions(viewer));
      if (reportRunnable == null) {
        throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{designFile});
      }
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}

Fixed version (ground truth):
/** 
 * Returns report design handle
 * @param request
 * @param viewer
 * @return
 * @throws Exception
 */
public static IViewerReportDesignHandle getDesignHandle(HttpServletRequest request,ViewerField viewer) throws Exception {
  if (viewer == null)   return null;
  IViewerReportDesignHandle design=null;
  IReportRunnable reportRunnable=null;
  String designFile=ParameterAccessor.getReport(request,viewer.getReportDesign());
  String documentFile=ParameterAccessor.getReportDocument(request,viewer.getReportDocument(),false);
  boolean isValidDocument=ParameterAccessor.isValidFilePath(viewer.getReportDocument());
  if (documentFile != null && isValidDocument) {
    try {
      IReportDocument reportDocumentInstance=ReportEngineService.getInstance().openReportDocument(designFile,documentFile,getModuleOptions(viewer));
      if (reportDocumentInstance != null) {
        viewer.setDocumentInUrl(true);
        reportRunnable=reportDocumentInstance.getReportRunnable();
        reportDocumentInstance.close();
      }
    }
 catch (    Exception e) {
    }
  }
  if (reportRunnable == null) {
    if (documentFile != null && designFile == null) {
      if (isValidDocument)       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_FILE_ERROR,new String[]{documentFile});
 else       throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_DOCUMENT_ACCESS_ERROR,new String[]{documentFile});
    }
    if (!ParameterAccessor.isValidFilePath(viewer.getReportDesign())) {
      throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_ACCESS_ERROR,new String[]{designFile});
    }
 else {
      reportRunnable=BirtUtility.getRunnableFromDesignFile(request,designFile,getModuleOptions(viewer));
      if (reportRunnable == null) {
        throw new ViewerException(ResourceConstants.GENERAL_EXCEPTION_REPORT_FILE_ERROR,new String[]{designFile});
      }
    }
  }
  if (reportRunnable != null) {
    design=new BirtViewerReportDesignHandle(IViewerReportDesignHandle.RPT_RUNNABLE_OBJECT,reportRunnable);
  }
  return design;
}