commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mart...@apache.org
Subject svn commit: r349339 - /jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java
Date Mon, 28 Nov 2005 01:18:43 GMT
Author: martinc
Date: Sun Nov 27 17:18:41 2005
New Revision: 349339

URL: http://svn.apache.org/viewcvs?rev=349339&view=rev
Log:
Make the temporary file names unique across class loaders, not just within them, by including
a UID in the file name.

Modified:
    jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java

Modified: jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java?rev=349339&r1=349338&r2=349339&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java
(original)
+++ jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java
Sun Nov 27 17:18:41 2005
@@ -25,6 +25,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.rmi.server.UID;
 import java.util.Map;
 import org.apache.commons.io.FileCleaner;
 import org.apache.commons.io.output.DeferredFileOutputStream;
@@ -83,6 +84,12 @@
 
 
     /**
+     * UID used in unique file name generation.
+     */
+    private static final String uid =
+            new UID().toString().replace(':', '_').replace('-', '_');
+
+    /**
      * Counter used in unique identifier generation.
      */
     private static int counter = 0;
@@ -564,7 +571,7 @@
             tempDir = new File(System.getProperty("java.io.tmpdir"));
         }
 
-        String fileName = "upload_" + getUniqueId() + ".tmp";
+        String fileName = "upload_" + uid + "_" + getUniqueId() + ".tmp";
 
         File f = new File(tempDir, fileName);
         FileCleaner.track(f, this);



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message