Created attachment 37272 [details] patch to prevent duplicate call to delete temporary file TL;DR: if we call the SXSSFWorkbook.dispose(), the finalizer of SheetDataWriter will attempt to delete the already deleted temporary files. The POI library will create an error log which in fact is a false alarm. The submitted patch is to check the existence of the file before calling the File.delete() method. Long version: According to the doc, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note that SXSSF allocates temporary files that you must always clean up explicitly, by calling the dispose method. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In our app, after we write the excel file using SXSSFWorkbook, we follow the guideline to call the method SXSSFWorkbook.dispose(). It will then iterate the SXSSFSheet and call SXSSFSheet.dispose() which in turn call the SheetDataWriter.dispose() method. This method will remove the temporary file created. boolean dispose() throws IOException { final boolean ret; try { _out.close(); } finally { ret = _fd.delete(); } return ret; } But the problem is, when the JVM GC run, it will call the SheetDataWriter.finalize() method, which will remove the same file again. @Override protected void finalize() throws Throwable { if (!_fd.delete()) { logger.log(POILogger.ERROR, "Can't delete temporary encryption file: "+_fd); } super.finalize(); } Although the app will not crash, this log is annoying and create a false alarm.
Comment on attachment 37272 [details] patch to prevent duplicate call to delete temporary file Thanks. Merged with https://svn.apache.org/repos/asf/poi/trunk@1878227