Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-2912

Short circuit with FileNotFoundException when a URL is empty

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Wish
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4
    • None
    • image/unqualified
    • None

    Description

      Hi, We use FOP to generate pdf reports through xsl-fo.  Sometimes the dynamic data from the xml results in an empty URL being passed to external-graphic src.  This makes its way through ExternalGraphic.java, and ends up in a needless and wasteful OS call to list the directory where our images are stored (file://<our_imagestore>/).  Some of our customers also have hundreds of thousands of images in that top level directory, and the OS dir call takes an immense amount of time to return (with a FileNotFoundException). 

      We are trying out this code in ExternalGraphic.java, line 80-81 (change in blue) in the trunk:

       
      public void bind(PropertyList pList) throws FOPException {
      super.bind(pList);
      src = pList.get(PR_SRC).getString();

      //Additional processing: obtain the image's intrinsic size and baseline information
      url = URISpecification.getURL(src);
      FOUserAgent userAgent = getUserAgent();
      ImageManager manager = userAgent.getImageManager();
      ImageInfo info = null;
      try {
         if (url == null || url.trim().isEmpty() || url.trim().equals("") || url.endsWith("/" ) || url.endsWith("
        "))

         {         throw new FileNotFoundException("URL is not complete");
         }

      info = manager.getImageInfo(url, userAgent.getImageSessionContext());

      -------

      It would be great if something like this could be adopted into the code so we do not need to maintain our own version.  I cannot think of a use case where an empty URL or a URL that specifies a directory would be valid (except maybe where a default file is served from a directory using http)?

      Please let me know what you think.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            cbuxbaum CARL BUXBAUM

            Dates

              Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified

              Slack

                Issue deployment