Question

I'm running into an exceedingly strange problem. I'm using commons-fileupload (1.2.1) to process file uploads in my webapp (hosted in tomcat 7.0.23, and the distributable flag is set). Once I get a DiskFileItem instance from my DiskFileItemFactory (no FileCleaningTracker), I use its write method to store the file (in the same directory that the DiskFileItemFactory was configured to use in case it needed to write the file to disk as it streamed in). The problem is that this new file (explicitly created and named by me) is then deleted after the request finishes processing. As you can imagine, this is problematic when I need to access the file again.

Tidbits that seem like they might be relevant:

  • The directory in question is not the default temp dir from the servlet context, nor is it underneath the Tomcat directory.
  • In an alternate code path, I copy that file immediately (not in a different request), and THAT copy does not get deleted.
  • Even if I chmod a-w the file before the request finishes, it still gets deleted when the request finishes.

Thanks for any help.

Was it helpful?

Solution

And the culprit? A stray finalize method from 9+ years ago doing "cleanup".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top