Uploaded image for project: 'XMLGraphicsCommons'
  1. XMLGraphicsCommons
  2. XGC-92

Cannot load SVGZ files when the URLConnection.getInputStream does not return directly a buffered input stream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 1.4
    • general
    • None

    Description

      I'm running Apache FOP to embed a SVGZ in a PDF document.
      The process which runs FOP has its own URLHandler implementation of the "file" URL protocol which on the method "getInputStream" returns directly the FileInputStream. (The SUN implementation of FileURLConnection returns a BufferedInputStream over the FileInputStream).

      The Input Stream is not properly re-used in org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext
      leading to the fact that after the first two bytes are read and the image is determined as SVGZ, the image source remains with the original input stream.

      The method AbstractImageSessionContext.newSource(String)

      has at some point an IF like:

      if (directFileAccess) {
      .....
      }
      

      there should also be an else branch on that IF clause containing:

                  } else {
                    if(source instanceof StreamSource && ImageUtil.hasInputStream(source)){
                      ((StreamSource)source).setInputStream(in);
                    }
                  }

      because that "in" variable has been already read and reset by the code above while the stream source will still contain the original FileInputStream from which the bytes have been read and which cannot be reset anymore.

      Attachments

        Activity

          People

            Unassigned Unassigned
            radu_coravu Radu Coravu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

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