martinc 2004/10/11 21:17:27
Modified: fileupload/src/java/org/apache/commons/fileupload
DefaultFileItem.java
Log:
Bug #27477 - Use FileCleaner from Commons IO to clean up temp files, rather
than File.deleteOnExit(), which can cause serious problems in
long-running processes.
Revision Changes Path
1.27 +6 -3
jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java
Index: DefaultFileItem.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- DefaultFileItem.java 11 Oct 2004 03:18:45 -0000 1.26
+++ DefaultFileItem.java 12 Oct 2004 04:17:27 -0000 1.27
@@ -26,6 +26,7 @@
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Map;
+import org.apache.commons.io.FileCleaner;
import org.apache.commons.io.output.DeferredFileOutputStream;
@@ -600,7 +601,9 @@
/**
* Creates and returns a [EMAIL PROTECTED] java.io.File File} representing a
uniquely
- * named temporary file in the configured repository path.
+ * named temporary file in the configured repository path. The lifetime of
+ * the file is tied to the lifetime of the <code>FileItem</code> instance;
+ * the file will be deleted when the instance is garbage collected.
*
* @return The [EMAIL PROTECTED] java.io.File File} to be used for temporary
storage.
*/
@@ -615,7 +618,7 @@
String fileName = "upload_" + getUniqueId() + ".tmp";
File f = new File(tempDir, fileName);
- f.deleteOnExit();
+ FileCleaner.track(f, this);
return f;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]