]> source.dussan.org Git - poi.git/commitdiff
bug 60153: findbugs OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE close opened streams...
authorJaven O'Neal <onealj@apache.org>
Sun, 9 Oct 2016 10:51:13 +0000 (10:51 +0000)
committerJaven O'Neal <onealj@apache.org>
Sun, 9 Oct 2016 10:51:13 +0000 (10:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763959 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java

index e9b0b8017e80a23f97d018770dd6aae3d52bf74d..30c54b910e61a65aa523d881557216cc6b1e2266 100644 (file)
@@ -92,8 +92,16 @@ public class SheetDataWriter {
      * @param  fd the file to write to\r
      */\r
     public Writer createWriter(File fd) throws IOException {\r
-        final OutputStream decorated = decorateOutputStream(new FileOutputStream(fd));\r
-        return new BufferedWriter(new OutputStreamWriter(decorated, "UTF-8"));\r
+        FileOutputStream fos = new FileOutputStream(fd);\r
+        OutputStream decorated;\r
+        try {\r
+            decorated = decorateOutputStream(fos);\r
+        } catch (final IOException e) {\r
+            fos.close();\r
+            throw e;\r
+        }\r
+        return new BufferedWriter(\r
+                new OutputStreamWriter(decorated, "UTF-8"));\r
     }\r
     \r
     /**\r
@@ -128,7 +136,13 @@ public class SheetDataWriter {
      */\r
     public InputStream getWorksheetXMLInputStream() throws IOException {\r
         File fd = getTempFile();\r
-        return decorateInputStream(new FileInputStream(fd));\r
+        FileInputStream fis = new FileInputStream(fd);\r
+        try {\r
+            return decorateInputStream(fis);\r
+        } catch (IOException e) {\r
+            fis.close();\r
+            throw e;\r
+        }\r
     }\r
     \r
     /**\r