You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2004/10/12 06:17:27 UTC
cvs commit: jakarta-commons/fileupload/src/java/org/apache/commons/fileupload DefaultFileItem.java
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 {@link 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 {@link 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org