commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Harper (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FILEUPLOAD-234) Bug in docs: tmp file delete conditions in "Resource Cleanup" section of "using.html"
Date Wed, 19 Aug 2015 17:29:46 GMT

    [ https://issues.apache.org/jira/browse/FILEUPLOAD-234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14703414#comment-14703414
] 

Jon Harper commented on FILEUPLOAD-234:
---------------------------------------

The section also has
"
Disabling cleanup of temporary files

To disable tracking of temporary files, you may set the FileCleaningTracker to null. Consequently,
created files will no longer be tracked. In particular, they will no longer be deleted automatically.
"
But disabling the tracking is not enough to prevent the file associated with DiskFileItem
to be deleted because DiskFileItem also has a finalize method which gets called by the garbage
collector at some point anyway.

So I would add in the intro
"
This is done silently either by the org.apache.commons.io.FileCleaner class, which starts
a reaper thread, or by the finalize() method of DiskFileItem, whichever is called first. Using
the reaper thread is optional. To use the reaper thread, see below. Usually, using the reaper
thread allows to remove the files earlier and more deterministically than waiting for the
garbage collector to call the finalize() method. It is not possible to disable the cleanup
of temporary files when DiskFileItem is garbage collected.
"
 and remove the "Disabling cleanup of temporary files" section:

Jon Harper

> Bug in docs: tmp file delete conditions in "Resource Cleanup" section of "using.html"
> -------------------------------------------------------------------------------------
>
>                 Key: FILEUPLOAD-234
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-234
>             Project: Commons FileUpload
>          Issue Type: Bug
>    Affects Versions: 1.3
>            Reporter: Evgeniy Philippov
>            Priority: Minor
>             Fix For: 1.4
>
>
> The guide at http://commons.apache.org/proper/commons-fileupload/using.html incorrectly
writes: "Such temporary files are deleted automatically, if they are no longer used (more
precisely, if the corresponding instance of java.io.File is garbage collected.".
> (The following affects maven version: http://search.maven.org/#artifactdetails|commons-fileupload|commons-fileupload|1.2.2|jar
)
> However, the code for org.apache.commons.io.FileCleaningTracker.Tracker.Tracker(...)
passes org.apache.commons.fileupload.disk.DiskFileItemFactory.this specified by org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(String,
String, boolean, String) in tracker.track(result.getTempFile(), this), and not java.io.File.
I.e. the "using.html" guide must be corrected.
> The correct (fixed) phrasing is: 
> "Such temporary files are deleted automatically, if they are no longer used (more precisely,
if the corresponding instance of org.apache.commons.fileupload.disk.DiskFileItemFactory is
garbage collected.".
> (The following affects maven version: http://search.maven.org/#artifactdetails|commons-fileupload|commons-fileupload|1.3|jar
)
> However, the code for org.apache.commons.io.FileCleaningTracker.Tracker.Tracker(...)
passes DiskFileItem.this specified by org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(String,
String, boolean, String) in DiskFileItem result=[...]; [...]; tracker.track(result.getTempFile(),
result), and not java.io.File. I.e. the "using.html" guide must be corrected.
> The correct (fixed) phrasing is: 
> "Such temporary files are deleted automatically, if they are no longer used (more precisely,
if the corresponding instance of org.apache.commons.fileupload.disk.DiskFileItem is garbage
collected.".
> (The following holds for both versions 1.2.2 and 1.3)
> The correct (fixed) phrasing is: 
> "Such temporary files are deleted automatically, if they are no longer used (more precisely,
if the corresponding instance of org.apache.commons.fileupload.disk.DiskFileItem (for commons-fileupload
v.1.3) and instance of org.apache.commons.fileupload.disk.DiskFileItemFactory (for commons-fileupload
v.1.2.2) is garbage collected.".



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message