PR: FileUpload-288
Avoid using File.exists() on temporary files, if we know that the file
has been created.
This closes #12.
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>taylor@apache.org</email>
</contributor>
+ <contributor>
+ <name>fangwentong</name>
+ <email>fangwentong2012@gmail.com</email>
+ </contributor>
+
</contributors>
<scm>
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 @@
</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="fangwentong2012@gmail.com">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>
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 void delete() {
cachedContent = null;
File outputFile = getStoreLocation();
- if (outputFile != null && outputFile.exists()) {
+ if (outputFile != null && !isInMemory() && outputFile.exists()) {
outputFile.delete();
}
}
@@ -566,6 +566,9 @@
*/
@Override
protected void finalize() {
+ if (dfos == null || dfos.isInMemory()) {
+ return;
+ }
File outputFile = dfos.getFile();
if (outputFile != null && outputFile.exists()) {