The offending function is here: https://github.com/apache/poi/blob/d94ff1aa8e92b443e06008c35e49a6d1f5f891ea/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java#L378 boolean dispose() throws IOException { _out.close(); return _fd.delete(); } The problem is when _out.close() throws an exception, the file handle is never deleted, and to my knowledge there is no way for an outside library user to EVER delete the file? I suggest the function be changed like so: boolean dispose() throws IOException { final boolean ret; try { _out.close(); } finally { ret = _fd.delete(); } return ret; } The way I stumbled upon this bug and what causes it to be a blocking issue is our /tmp is a tmpfs mount with a 2 gigabyte size limit, temporary compression was turned off and SXSSF created a temporary .xml file that filled up the 2 gigabyte limit on /tmp, an exception was thrown from .flush() that the drive was out of space, and when .dispose() was called in a finally block it did not delete the file, causing all subsequent runs of SXSSF to fail in the same way since the drive was still full. If I can provide more info or help please let me know. Thanks!
Thanks for the patch! Applied in r1738848. Do you think you could also write a unit test to simulate running out of disk space (might need to create some OutputStream that has a fixed size that you can easily exceed)?
I took a look and did not see an easy way to do unit-testing of this particular feature. Some other unit-tests cover the "good" case of deleting the file already, the rest needs to be tested manually for now... Still setting this to fixed as the code was adjusted accordingly.