Bug 53470 - control delete temp files
Summary: control delete temp files
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: 3.8-FINAL
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-26 14:19 UTC by Massimo Cavalleri
Modified: 2012-07-01 15:20 UTC (History)
0 users



Attachments
small patch to add delete temp files inside wb.write method (811 bytes, patch)
2012-06-28 13:35 UTC, Massimo Cavalleri
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Massimo Cavalleri 2012-06-26 14:19:11 UTC
I have a request for control delete of temp files that SXSSF create automatically.

es.:

poi-sxssf-sheet-xml127328075585779261.gz

when compress is active or

poi-sxssf-sheet127328075585779261

There are two alternatives:

1) add delete method to SXSSFWorkbook
2) add new Constructor to SXSSFWorkbook with this signature: SXSSFWorkbook(File tmpDir, int rowAccessWindowSize)  

For you what is the best solution?

I can write a patch for this...
Comment 1 Massimo Cavalleri 2012-06-28 13:35:38 UTC
Created attachment 29004 [details]
small patch to add delete temp files inside wb.write method
Comment 2 Massimo Cavalleri 2012-06-28 13:38:08 UTC
Comment on attachment 29004 [details]
small patch to add delete temp files inside wb.write method

patch for org/apache/poi/xssf/streaming
Comment 3 Massimo Cavalleri 2012-06-28 14:17:28 UTC
Comment on attachment 29004 [details]
small patch to add delete temp files inside wb.write method

This is very rudimental patch, this is an example.
I don't know the structure of SXSSF classes.

This is a different way than two alternatives that i have described.

I think to insert code for delete temp files in Workbook.write method because when this is call, the temp files is unuseful.
Comment 4 Nick Burch 2012-06-28 16:49:32 UTC
What's wrong with just supplying a different value to the java.io.tmpdir property?

Once you're done with a SXSSF file, the temp files should be being cleaned up. If they're not, that'd be a bug
Comment 5 Massimo Cavalleri 2012-06-29 07:48:56 UTC
ok, java.io.tmpdir property is useful but i tell of Custructor with File for control temp files, but after i have choose a different way in my patch.

Yes, in poi's source there is deleteOnExit() on temp files but with this way, when i write a workbook, files persist if i don't exit from JVM.
Therefore if you try my patch, resolve this issue.
In conclusion this is a BUG.
Comment 6 Massimo Cavalleri 2012-06-29 07:50:40 UTC
(In reply to comment #4)
> What's wrong with just supplying a different value to the java.io.tmpdir
> property?
> 


ok, java.io.tmpdir property is useful but i tell of Custructor with File for control temp files, but after i have choose a different way in my patch.

> Once you're done with a SXSSF file, the temp files should be being cleaned
> up. If they're not, that'd be a bug

Yes, in poi's source there is deleteOnExit() on temp files but with this way, when i write a workbook, files persist if i don't exit from JVM.
Therefore if you try my patch, resolve this issue.
In conclusion this is a BUG.
Comment 7 Nick Burch 2012-06-30 13:24:35 UTC
I would have expected that SXSSF would tidy up after itself once it's done with the file. Are you trying to tidy up part way through processing a file for some reason, or are you finding that the temp files are left around once SXSSF has completed its work?
Comment 8 Massimo Cavalleri 2012-07-01 10:55:45 UTC
The the temp files not deleted when call write method.

In the SXSSF code there is not a part for this purpose.

There is only _fd.deleteOnExit() in SheetDataWriter class, but is not enough if the program that use POI not exit from jvm and these files remain on file system.

For confirm this, in the method write in SXSSFWorkbook class, there is already tmplFile.delete() for another tmp file.

In conclusion in write method missing the delete on xml's temporary files.
Comment 9 Nick Burch 2012-07-01 14:49:31 UTC
I would suggest you open a new bug against SXSSF then - I believe the correct solution is to have SXSSF tidy up when it's done with files, rather than requiring users to do that via explicit temp directory controls.
Comment 10 Massimo Cavalleri 2012-07-01 15:03:46 UTC
i not understand... i must open a new bug?!
Comment 11 Massimo Cavalleri 2012-07-01 15:20:27 UTC
i open new bug 

https://issues.apache.org/bugzilla/show_bug.cgi?id=53493