try to handle logging issue where DeferredSXSSFWorkbook close can lead to logging about close already having been called

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894951 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-11-11 13:24:37 +00:00
parent 66461e1e68
commit 530af684b3
1 changed files with 8 additions and 2 deletions

View 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;
}
}