Add maxSize to BinaryDataProvider so the payload size could be constrained (to 1Gb by default)#3301
Open
reta wants to merge 1 commit into
Open
Add maxSize to BinaryDataProvider so the payload size could be constrained (to 1Gb by default)#3301reta wants to merge 1 commit into
maxSize to BinaryDataProvider so the payload size could be constrained (to 1Gb by default)#3301reta wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a configurable maximum payload size for binary reads (defaulting to 1GiB via a system property), and threads that limit through core stream utilities so byte-array materialization can be constrained.
Changes:
- Add
maxSize(default fromorg.apache.cxf.binary-max-size) toBinaryDataProviderand apply it tobyte[]reads. - Extend
IOUtilswith size-limited stream-to-bytes support and acopy(..., maxSize)variant, deprecating the unlimitedreadBytesFromStream(InputStream). - Update
CachedOutputStream#getBytes()to use the new size-limitedIOUtils.readBytesFromStream(...)path and add a unit test for theBinaryDataProvidermax-size behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java | Adds maxSize configuration and uses it when reading byte[] entities. |
| rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java | Adds a test asserting an exception is thrown when the configured max size is exceeded. |
| core/src/main/java/org/apache/cxf/helpers/IOUtils.java | Adds max-size-aware copy/read APIs used to bound in-memory buffering. |
| core/src/main/java/org/apache/cxf/io/CachedOutputStream.java | Routes file-backed getBytes() reads through the new max-size-aware read helper. |
| core/src/main/java/org/apache/cxf/helpers/CastUtils.java | Adds a long-to-int conversion helper used when passing limits to int-based APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ained (to 1Gb by default)
coheigea
reviewed
Jul 10, 2026
coheigea
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
maxSizeto BinaryDataProvider so the payload size could be constrained (to 1Gb by default). Adding a new system propertyorg.apache.cxf.binary-max-sizeto configure the default.