poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1763959 - /poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
Date Sun, 09 Oct 2016 10:51:13 GMT
Author: onealj
Date: Sun Oct  9 10:51:13 2016
New Revision: 1763959

URL: http://svn.apache.org/viewvc?rev=1763959&view=rev
Log:
bug 60153: findbugs OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE close opened streams if an exception
is raised while decorating the stream

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java?rev=1763959&r1=1763958&r2=1763959&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java Sun Oct  9
10:51:13 2016
@@ -92,8 +92,16 @@ public class SheetDataWriter {
      * @param  fd the file to write to
      */
     public Writer createWriter(File fd) throws IOException {
-        final OutputStream decorated = decorateOutputStream(new FileOutputStream(fd));
-        return new BufferedWriter(new OutputStreamWriter(decorated, "UTF-8"));
+        FileOutputStream fos = new FileOutputStream(fd);
+        OutputStream decorated;
+        try {
+            decorated = decorateOutputStream(fos);
+        } catch (final IOException e) {
+            fos.close();
+            throw e;
+        }
+        return new BufferedWriter(
+                new OutputStreamWriter(decorated, "UTF-8"));
     }
     
     /**
@@ -128,7 +136,13 @@ public class SheetDataWriter {
      */
     public InputStream getWorksheetXMLInputStream() throws IOException {
         File fd = getTempFile();
-        return decorateInputStream(new FileInputStream(fd));
+        FileInputStream fis = new FileInputStream(fd);
+        try {
+            return decorateInputStream(fis);
+        } catch (IOException e) {
+            fis.close();
+            throw e;
+        }
     }
     
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message