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


The following commit(s) were added to refs/heads/master by this push:
     new 6dfa0aa4 Update to non-deprecated APIs
     new 0d789861 Merge branch 'master' of 
https://github.com/apache/commons-fileupload.git
6dfa0aa4 is described below

commit 6dfa0aa45d0f5e5ee30c261fa6410fb8a433c1bf
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Jun 13 11:08:27 2025 -0400

    Update to non-deprecated APIs
---
 .../fileupload2/core/FileItemInputIteratorImpl.java       | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
index 6dc63457..3815baa8 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
@@ -263,13 +263,16 @@ class FileItemInputIteratorImpl implements 
FileItemInputIterator {
                         requestSize);
             }
             // This is eventually closed in MultipartInput processing
-            inputStream = new 
BoundedInputStream(requestContext.getInputStream(), sizeMax) {
-                @Override
-                protected void onMaxLength(final long maxLen, final long 
count) throws IOException {
+            // @formatter:off
+            inputStream = BoundedInputStream.builder()
+                .setInputStream(requestContext.getInputStream())
+                .setMaxCount(sizeMax)
+                .setOnMaxCount((max, count) -> {
                     throw new FileUploadSizeException(
-                            String.format("The request was rejected because 
its size (%s) exceeds the configured maximum (%s)", count, maxLen), maxLen, 
count);
-                }
-            };
+                        String.format("The request was rejected because its 
size (%s) exceeds the configured maximum (%s)", count, max), max, count);
+                })
+                .get();
+            // @formatter:on
         } else {
             inputStream = requestContext.getInputStream();
         }

Reply via email to