]> source.dussan.org Git - poi.git/commitdiff
try to handle logging issue where DeferredSXSSFWorkbook close can lead to logging...
authorPJ Fanning <fanningpj@apache.org>
Thu, 11 Nov 2021 13:24:37 +0000 (13:24 +0000)
committerPJ Fanning <fanningpj@apache.org>
Thu, 11 Nov 2021 13:24:37 +0000 (13:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894951 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/StreamingSheetWriter.java

index 173e6963bdb9f571ac1d9ae397115f3954c461d2..1e467244f5df5dddc8e8c23f0b3ce7dca6f6cd81 100644 (file)
@@ -37,6 +37,7 @@ import org.apache.poi.util.Beta;
 @Beta
 public class StreamingSheetWriter extends SheetDataWriter {
     private static final Logger LOG = LogManager.getLogger(StreamingSheetWriter.class);
+    private boolean closed = false;
 
     public StreamingSheetWriter() throws IOException {
         throw new RuntimeException("StreamingSheetWriter requires OutputStream");
@@ -68,7 +69,9 @@ public class StreamingSheetWriter extends SheetDataWriter {
 
     @Override
     public void close() throws IOException {
-        _out.flush();
+        if (!closed) {
+            _out.flush();
+        }
     }
 
     @Override
@@ -78,7 +81,10 @@ public class StreamingSheetWriter extends SheetDataWriter {
 
     @Override
     boolean dispose() throws IOException {
-        _out.close();
+        if (!closed) {
+            _out.close();
+        }
+        closed = true;
         return true;
     }
 }