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.