https://bz.apache.org/bugzilla/show_bug.cgi?id=64477
Bug ID: 64477 Summary: [PATCH] prevent duplicate delete of temporary file of SXSSF SheetDataWriter Product: POI Version: 4.1.2-FINAL Hardware: PC OS: All Status: NEW Severity: normal Priority: P2 Component: SXSSF Assignee: dev@poi.apache.org Reporter: neo.w...@gmail.com Target Milestone: --- Created attachment 37272 --> https://bz.apache.org/bugzilla/attachment.cgi?id=37272&action=edit 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. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org