This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch 1.x
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
The following commit(s) were added to refs/heads/1.x by this push:
new f58296ad Javadoc that you shouldn't rely on the garbage collection to
cause the JVM to call FileItem.delete() through finalization
f58296ad is described below
commit f58296ad9c72ee561262afd95177f37208a35e14
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Apr 9 17:42:33 2026 -0400
Javadoc that you shouldn't rely on the garbage collection to cause the
JVM to call FileItem.delete() through finalization
See JEP 421: Deprecate Finalization for Removal.
---
src/changes/changes.xml | 1 +
.../org/apache/commons/fileupload/FileItem.java | 42 +++++++++++-----------
2 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8ca32b0c..7ead62f3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary
Gregory">org.apache.commons.fileupload.util.Closeable now extends
java.io.Closeable.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">If
DiskFileItem.delete() can't delete the file, it marks it for deletion on JVM
exit.</action>
<action type="fix" dev="ggregory" due-to="Gary
Gregory">DiskFileItem.delete() and finalize() always ties to delete its backing
file.</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Javadoc that you
shouldn't rely on the garbage collection to cause the JVM to call
FileItem.delete() through finalization; see JEP 421: Deprecate Finalization for
Removal.</action>
<!-- ADD -->
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump
org.apache.commons:commons-parent from 84 to 98.</action>
diff --git a/src/main/java/org/apache/commons/fileupload/FileItem.java
b/src/main/java/org/apache/commons/fileupload/FileItem.java
index 6caeb1fe..391b8423 100644
--- a/src/main/java/org/apache/commons/fileupload/FileItem.java
+++ b/src/main/java/org/apache/commons/fileupload/FileItem.java
@@ -23,35 +23,33 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
/**
- * <p> This class represents a file or form item that was received within a
- * {@code multipart/form-data} POST request.
- *
- * <p> After retrieving an instance of this class from a {@link
- * org.apache.commons.fileupload.FileUpload FileUpload} instance (see
- * {@link org.apache.commons.fileupload.servlet.ServletFileUpload
- * #parseRequest(javax.servlet.http.HttpServletRequest)}), you may
- * either request all contents of the file at once using {@link #get()} or
- * request an {@link java.io.InputStream InputStream} with
- * {@link #getInputStream()} and process the file without attempting to load
- * it into memory, which may come handy with large files.
- *
- * <p> While this interface does not extend
- * {@code javax.activation.DataSource} per se (to avoid a seldom used
- * dependency), several of the defined methods are specifically defined with
- * the same signatures as methods in that interface. This allows an
- * implementation of this interface to also implement
+ * Represents a file or form item that was received within a {@code
multipart/form-data} POST request.
+ * <p>
+ * Although the underlying storage will be deleted automatically when the
{@code FileItem} instance is garbage collected, you shouldn't rely on this
behavior
+ * because it is deprecated in Java 18 with <a
href="https://openjdk.org/jeps/421">JEP 421: Deprecate Finalization for
Removal</a>.
+ * </p>
+ * <p>
+ * After retrieving an instance of this class from a {@link
org.apache.commons.fileupload.FileUpload FileUpload} instance (see
+ * {@link org.apache.commons.fileupload.servlet.ServletFileUpload
#parseRequest(javax.servlet.http.HttpServletRequest)}), you may either request
all contents of
+ * the file at once using {@link #get()} or request an {@link
java.io.InputStream InputStream} with {@link #getInputStream()} and process the
file without
+ * attempting to load it into memory, which may come handy with large files.
+ * </p>
+ * <p>
+ * While this interface does not extend {@code javax.activation.DataSource}
per se (to avoid a seldom used dependency), several of the defined methods are
+ * specifically defined with the same signatures as methods in that interface.
This allows an implementation of this interface to also implement
* {@code javax.activation.DataSource} with minimal additional work.
+ * </p>
*
* @since 1.3 additionally implements FileItemHeadersSupport
*/
public interface FileItem extends FileItemHeadersSupport {
/**
- * Deletes the underlying storage for a file item, including deleting any
- * associated temporary disk file. Although this storage will be deleted
- * automatically when the {@code FileItem} instance is garbage
- * collected, this method can be used to ensure that this is done at an
- * earlier time, thus preserving system resources.
+ * Deletes the underlying storage for a file item, including deleting any
associated temporary disk file.
+ * <p>
+ * Although the underlying storage will be deleted automatically when the
{@code FileItem} instance is garbage collected, you shouldn't rely on this
+ * behavior because it is deprecated in Java 18 with <a
href="https://openjdk.org/jeps/421">JEP 421: Deprecate Finalization for
Removal</a>.
+ * </p>
*/
void delete();