From 151b4472f3b2ea7a7ea820dee6d4c617d3864a2a Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Fri, 3 May 2019 18:41:30 +0100 Subject: [PATCH] Fix SpotBugs warning --- .../tomcat/util/http/fileupload/disk/DiskFileItem.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java index 38c783e15713..3992162470a8 100644 --- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java +++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java @@ -392,7 +392,10 @@ public void write(File file) throws Exception { * desired file. */ if (file.exists()) { - file.delete(); + if (!file.delete()) { + throw new FileUploadException( + "Cannot write uploaded file to disk!"); + } } if (!outputFile.renameTo(file)) { BufferedInputStream in = null;