Why is it not a bad idea to delete things at garbage collection time!

satya - 4/13/2014 11:21:05 AM

This came about when I am using the Apache commons file upload

This came about when I am using the Apache commons file upload

satya - 4/13/2014 11:21:41 AM

Here is that link

Here is that link

satya - 4/13/2014 11:22:11 AM

Here is the commons API. See for FileItem

Here is the commons API. See for FileItem

satya - 4/13/2014 11:25:27 AM

Here is the gist

the FileItem object deletes the file when it is garbage collected. This is ok, and looks like a good precaution if one is to explicitly forgot to call delete on it.

however if you want to wait for a subsequent time to process that file and if the garbage collector is to kick off, you may loose the file unintentionally! This means either you have to carry that FileItem as is and keep it alive or immediately transfer it to a file.

More to think on this, and see what the general recommendation and experience is of people doing things on garbage collection...