Repository: commons-fileupload Updated Branches: refs/heads/master b57dcf4d3 -> 4242ff461
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/180f6138 Tree: http://git-wip-us.apache.org/repos/asf/commons-fileupload/tree/180f6138 Diff: http://git-wip-us.apache.org/repos/asf/commons-fileupload/diff/180f6138 Branch: refs/heads/master Commit: 180f6138b185a03ae1ee154b8048d67cf23af181 Parents: 2434446 Author: Jochen Wiedmann (jwi) <[email protected]> Authored: Thu Nov 23 21:07:27 2017 +0100 Committer: Jochen Wiedmann (jwi) <[email protected]> Committed: Thu Nov 23 21:07:27 2017 +0100 ---------------------------------------------------------------------- pom.xml | 4 ++++ src/changes/changes.xml | 1 + .../java/org/apache/commons/fileupload/disk/DiskFileItem.java | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/180f6138/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index b097ac2..322472a 100644 --- a/pom.xml +++ b/pom.xml @@ -173,6 +173,10 @@ <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/180f6138/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 55798e0..ec6823d 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -61,6 +61,7 @@ The <action> type attribute can be add,update,fix,remove. <action dev="ecki" type="add">Site: added security report</action> <action dev="markt" due-to="Felix Schumacher">Improve performance for large multi-part boundaries</action> <action issue="FILEUPLOAD-286" dev="jochen" due-to="maxxedev" due-to-email="[email protected]">Added the default character set to the DiskFileItem.</action> + <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.3" date="2017-06-13"> http://git-wip-us.apache.org/repos/asf/commons-fileupload/blob/180f6138/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 48004f3..1802131 100644 --- a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java +++ b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java @@ -415,7 +415,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(); } } @@ -523,7 +523,7 @@ public class DiskFileItem */ @Override protected void finalize() { - if (dfos == null) { + if (dfos == null || dfos.isInMemory()) { return; } File outputFile = dfos.getFile();
