commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davis Ford <>
Subject FileCleanerCleanup question
Date Mon, 19 Oct 2009 16:06:55 GMT
Hi, it is my understanding from the commons-io javadoc, that if you create a
FileCleanerCleanup it will remove files in a directory once the reference to
the File is GC'd.

Given that, I'm using commons-fileupload, and I set the listener in web.xml



In my servlet, I have this:

private static FileCleaningTracker tracker;

    protected void initServletContext(ServletContext servletContext) {
        tracker = FileCleanerCleanup.getFileCleaningTracker(servletContext);

...and in my method that accepts a file upload, I add the

final DiskFileItemFactory factory = new DiskFileItemFactory(0, tempDir);
final ServletFileUpload upload = new ServletFileUpload(factory);

My files are uploaded and stored in the temp directory as expected.  In the
processing of a file upload, I store the FileItem object in the session as
an attribute.  Now, if the session expires, I expect the attribute to be
GC'd and as a result, the FileCleanerCleanup would go and cleanup the
directory, but it does not.

Can anyone tell me what I may be doing wrong?

Thanks in advance,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message