This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 43b882b8a577684498ab9b8851aa0427216784f7
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 15 22:53:24 2023 +0100

    Restore the finalize() method
---
 .../tomcat/util/http/fileupload/disk/DiskFileItem.java    | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

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 d7cd4798fb..bc2067b24a 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -531,6 +531,21 @@ public class DiskFileItem
 
     // ------------------------------------------------------ Protected methods
 
+    /**
+     * Removes the file contents from the temporary storage.
+     */
+    @Override
+    protected void finalize() {
+        if (dfos == null || dfos.isInMemory()) {
+            return;
+        }
+        final File outputFile = dfos.getFile();
+
+        if (outputFile != null && outputFile.exists()) {
+            outputFile.delete();
+        }
+    }
+
     /**
      * Creates and returns a {@link java.io.File File} representing a uniquely
      * named temporary file in the configured repository path. The lifetime of


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to