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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git

commit 97cba303e2429e6cfdc99f5b05aa3a3c2b367b1b
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Jun 13 14:55:39 2025 -0400

    Update to non-deprecated APIs
---
 .../apache/commons/fileupload2/core/FileItemInputImpl.java | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
index a5b567fc..2f1c287c 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
@@ -100,15 +100,19 @@ class FileItemInputImpl implements FileItemInput {
             // onMaxLength will be called when the length is greater than _or 
equal to_ the supplied maxLength.
             // Because we only want to throw an exception when the length is 
greater than fileSizeMax, we
             // increment fileSizeMax by 1.
-            istream = new BoundedInputStream(istream, fileSizeMax + 1) {
-                @Override
-                protected void onMaxLength(final long sizeMax, final long 
count) throws IOException {
+            // @formatter:off
+            istream = BoundedInputStream.builder()
+                .setInputStream(istream)
+                .setMaxCount(fileSizeMax + 1)
+                .setOnMaxCount((max, count) -> {
                     itemInputStream.close(true);
                     throw new FileUploadByteCountLimitException(
                             String.format("The field %s exceeds its maximum 
permitted size of %s bytes.", fieldName, fileSizeMax), count, fileSizeMax, 
fileName,
                             fieldName);
-                }
-            };
+                })
+                .get();
+            // @formatter:on
+
         }
         this.inputStream = istream;
     }

Reply via email to