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

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

commit c99ffc30e95ddc4daede564d08cb5ea2b9a9da65
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 bf4022164d..7fcd7f7653 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -528,6 +528,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