Details
-
Wish
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.4
-
None
-
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.