Created attachment 37549 [details] Exception stack trace The SXSSFSheet has a bug where it will fail to delete the temporary file it has created when the file system runs out of space. I found this problem when creating a very large excel workbook using SXSSFWorkbook. Attempting to write a new row fails (no space left), my code then attempts to cleanup by calling dispose(). This fails because the workbook attempts to flush before disposing and the flush fails with same IOException (no space left). The large amount of disk space consumed by the temporary file is only freed up when the program exits. I have attached a screenshot with the stack trace. Here is the code in question (poi-ooxml-4.1.2) https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java#L1910 boolean dispose() throws IOException { if (!allFlushed) { flushRows(); } return _writer.dispose(); } I suggest this be changed so that the writer.dispose() is always called. boolean dispose() throws IOException { try { if (!allFlushed) { flushRows(); } } finally { return _writer.dispose(); } } Let me know if you have any more questions.
Created attachment 37550 [details] SXSSFSheet patch
Attached Patch file with slight change from my original suggestion boolean dispose() throws IOException { boolean ret; try { if (!allFlushed) { flushRows(); } } finally { ret = _writer == null || _writer.dispose(); } return ret; }
merged with https://github.com/apache/poi/commit/90a9288bfc024985dd2a42ea4f319a27bc305ee1 and https://github.com/apache/poi/commit/578b71b127aa2da6f0f051973342790804aa705f