You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/06/13 18:59:34 UTC
(commons-fileupload) branch master updated (0d789861 -> 89c4db18)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
from 0d789861 Merge branch 'master' of https://github.com/apache/commons-fileupload.git
new 97cba303 Update to non-deprecated APIs
new 89c4db18 Remove unnecessary type cast
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/commons/fileupload2/core/FileItemInputImpl.java | 14 +++++++++-----
.../apache/commons/fileupload2/core/MultipartInput.java | 9 +++------
2 files changed, 12 insertions(+), 11 deletions(-)
(commons-fileupload) 01/02: Update to non-deprecated APIs
Posted by gg...@apache.org.
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 <ga...@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;
}
(commons-fileupload) 02/02: Remove unnecessary type cast
Posted by gg...@apache.org.
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 89c4db18419a2885359dda8c6e5443bc101e183b
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 13 14:57:30 2025 -0400
Remove unnecessary type cast
---
.../java/org/apache/commons/fileupload2/core/MultipartInput.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java
index 370f087c..18ff991b 100644
--- a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java
+++ b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java
@@ -937,11 +937,9 @@ public final class MultipartInput {
throw new MalformedStreamException("Stream ended unexpectedly", e);
}
final int phsm = getPartHeaderSizeMax();
- if (phsm != -1 && ++size > phsm) {
- throw new FileUploadSizeException(String.format(
- "Header section has more than %s bytes (maybe it"
- + " is not properly terminated)", Integer.valueOf(phsm)),
- (long) phsm, (long) size);
+ if (phsm != -1 && ++size > phsm) {
+ throw new FileUploadSizeException(
+ String.format("Header section has more than %s bytes (maybe it is not properly terminated)", Integer.valueOf(phsm)), phsm, size);
}
if (b == HEADER_SEPARATOR[i]) {
i++;
@@ -950,7 +948,6 @@ public final class MultipartInput {
}
baos.write(b);
}
-
try {
return baos.toString(Charsets.toCharset(headerCharset, Charset.defaultCharset()).name());
} catch (final UnsupportedEncodingException e) {