pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1868150 - /pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java
Date Tue, 08 Oct 2019 16:12:26 GMT
Author: tilman
Date: Tue Oct  8 16:12:26 2019
New Revision: 1868150

URL: http://svn.apache.org/viewvc?rev=1868150&view=rev
Log:
PDFBOX-4665: close file on exception, as suggested by Chris Cockayne

Modified:
    pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java

Modified: pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java?rev=1868150&r1=1868149&r2=1868150&view=diff
==============================================================================
--- pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java
(original)
+++ pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PDImageXObject.java
Tue Oct  8 16:12:26 2019
@@ -226,10 +226,16 @@ public final class PDImageXObject extend
         String ext = name.substring(dot + 1).toLowerCase();
         if ("jpg".equals(ext) || "jpeg".equals(ext))
         {
-            FileInputStream fis = new FileInputStream(file);
-            PDImageXObject imageXObject = JPEGFactory.createFromStream(doc, fis);
-            fis.close();
-            return imageXObject;
+            FileInputStream fis = null;
+            try
+            {
+                fis = new FileInputStream(file);
+                return JPEGFactory.createFromStream(doc, fis);
+            }
+            finally
+            {
+                IOUtils.closeQuietly(fis);
+            }
         }
         if ("tif".equals(ext) || "tiff".equals(ext))
         {



Mime
View raw message