Bug 68183 - SXSSFWorkbook should dispose of temporary files when close() is called
Summary: SXSSFWorkbook should dispose of temporary files when close() is called
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: 5.2.3-FINAL
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-20 16:21 UTC by Clayton Bodendein
Modified: 2024-02-08 17:22 UTC (History)
1 user (show)



Attachments
Proof-of-concept git diff of the change required to implement this feature (2.10 KB, patch)
2023-11-20 16:21 UTC, Clayton Bodendein
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Clayton Bodendein 2023-11-20 16:21:14 UTC
Created attachment 39390 [details]
Proof-of-concept git diff of the change required to implement this feature

SXSSFWorkbooks create temporary files to back the workbook on disk. To get rid of those temporary files, a user is required to explicitly call the SXSSFWorkbook#dispose method otherwise those temporary files will not be cleaned up.

Workbooks are auto-closable so it would improve the developer experience if the SXSSFWorkbook#close method would call the SXSSFWorkbook#dispose method so that users don't need to always explicitly call SXSSFWorkbook#dispose.

For example, if this were implemented a user using a try-with-resources statement like this would always ensure that the temporary files are cleaned up:

try (Workbook wb = new SXSSFWorkbook()) {
    // create the sheets, rows, cells, etc.
    wb.write(oStream);
}



Attached is a git diff of this proposal with some accompanying Javadoc changes. It might also make sense to deprecate the SXSSFWorkbook#dispose method altogether and encourage users to just call SXSSFWorkbook#close but I didn't include that in the git diff.
Comment 1 Clayton Bodendein 2024-02-08 17:22:44 UTC
I created a pull request on GitHub for this here: https://github.com/apache/poi/pull/586