Repository: commons-fileupload
Updated Branches:
  refs/heads/b1_3 18734e9f7 -> 0e9fb5148


PR: FileUpload-288
Avoid using File.exists() on temporary files, if we know that the file
has been created.
This closes #12.


Project: http://git-wip-us.apache.org/repos/asf/commons-fileupload/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/commons-fileupload/commit/0e9fb514
Tree: http://git-wip-us.apache.org/repos/asf/commons-fileupload/tree/0e9fb514
Diff: http://git-wip-us.apache.org/repos/asf/commons-fileupload/diff/0e9fb514

Branch: refs/heads/b1_3
Commit: 0e9fb5148345d2aaaeccfb8f56e63c3080a83676
Parents: 18734e9
Author: Jochen Wiedmann (jwi) <[email protected]>
Authored: Thu Nov 23 21:40:32 2017 +0100
Committer: Jochen Wiedmann (jwi) <[email protected]>
Committed: Thu Nov 23 21:40:32 2017 +0100

----------------------------------------------------------------------
 pom.xml                                                         | 5 +++++
 src/changes/changes.xml                                         | 5 ++++-
 .../java/org/apache/commons/fileupload/disk/DiskFileItem.java   | 5 ++++-
 3 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/0e9fb514/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 154f19c..bddf7de 100644
--- a/pom.xml
+++ b/pom.xml
@@ -170,6 +170,11 @@
       <name>David Sean Taylor</name>
       <email>[email protected]</email>
     </contributor>
+    <contributor>
+      <name>fangwentong</name>
+      <email>[email protected]</email>
+    </contributor>
+    
   </contributors>
 
   <scm>

http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/0e9fb514/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 73f2613..6435c55 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -43,7 +43,10 @@ The <action> type attribute can be add,update,fix,remove.
   </properties>
 
   <body>
-    <release version="1.3.3" description="Bugfix release for 1.3.2" date="tba">
+    <release version="1.3.4" description="Bugfix release for 1.3.3" date="tba">
+      <action issue="FILEUPLOAD-288" dev="jochen" due-to="fangwentong" 
due-to-email="[email protected]">Avoid using File.exists() on temporary 
files, if we know that the file has been created.</action>
+    </release>
+    <release version="1.3.3" description="Bugfix release for 1.3.2" 
date="2017-06-13">
       <action issue="FILEUPLOAD-279" dev="jochen" type="fix">
         DiskDileItem can actually no longer be deserialized, unless a system 
property is set to true.
       </action>

http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/0e9fb514/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java 
b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
index 00eda95..e11d938 100644
--- a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
+++ b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
@@ -461,7 +461,7 @@ public class DiskFileItem
     public void delete() {
         cachedContent = null;
         File outputFile = getStoreLocation();
-        if (outputFile != null && outputFile.exists()) {
+        if (outputFile != null && !isInMemory()  &&  outputFile.exists()) {
             outputFile.delete();
         }
     }
@@ -566,6 +566,9 @@ public class DiskFileItem
      */
     @Override
     protected void finalize() {
+        if (dfos == null  ||  dfos.isInMemory()) {
+            return;
+        }
         File outputFile = dfos.getFile();
 
         if (outputFile != null && outputFile.exists()) {

Reply via email to