]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
patch from Stephen Fry
authoreschaeffer <eschaeffer@unknown>
Fri, 24 Nov 2000 13:38:36 +0000 (13:38 +0000)
committereschaeffer <eschaeffer@unknown>
Fri, 24 Nov 2000 13:38:36 +0000 (13:38 +0000)
in case of errors, input stream is closed.
PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193835 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/image/FopImageFactory.java

index fda25c21ddb764a66bea5d4f98259aa6151eeea3..995a62a6037a71b3e14a59a5af55e1f41b0ba9c1 100644 (file)
@@ -42,6 +42,7 @@ package org.apache.fop.image;
 
 // Java
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.lang.reflect.Constructor;
@@ -110,14 +111,17 @@ public class FopImageFactory {
 
     // If not, check image type
     ImageReader imgReader = null;
+               InputStream imgIS = null;
     try {
-      imgReader =
-        ImageReaderFactory.Make(absoluteURL.openStream());
+                       imgIS = absoluteURL.openStream();
+      imgReader = ImageReaderFactory.Make(imgIS);
     } catch (Exception e) {
       throw new FopImageException(
         "Error while recovering Image Informations (" +
         absoluteURL.toString() + ") : " + e.getMessage());
-    }
+    } finally {
+                       try {imgIS.close();} catch (IOException e) {}
+               }
     if (imgReader == null)
       throw new FopImageException("No ImageReader for this type of image (" +
                                   absoluteURL.toString() + ")");