Skip to content

Add maxSize to BinaryDataProvider so the payload size could be constrained (to 1Gb by default)#3301

Open
reta wants to merge 1 commit into
apache:mainfrom
reta:add.max.size
Open

Add maxSize to BinaryDataProvider so the payload size could be constrained (to 1Gb by default)#3301
reta wants to merge 1 commit into
apache:mainfrom
reta:add.max.size

Conversation

@reta

@reta reta commented Jul 9, 2026

Copy link
Copy Markdown
Member

Add maxSize to BinaryDataProvider so the payload size could be constrained (to 1Gb by default). Adding a new system property org.apache.cxf.binary-max-size to configure the default.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from org.apache.cxf.binary-max-size) to BinaryDataProvider and apply it to byte[] reads.
  • Extend IOUtils with size-limited stream-to-bytes support and a copy(..., maxSize) variant, deprecating the unlimited readBytesFromStream(InputStream).
  • Update CachedOutputStream#getBytes() to use the new size-limited IOUtils.readBytesFromStream(...) path and add a unit test for the BinaryDataProvider max-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.

Comment thread core/src/main/java/org/apache/cxf/helpers/IOUtils.java
Comment thread core/src/main/java/org/apache/cxf/io/CachedOutputStream.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread core/src/main/java/org/apache/cxf/helpers/IOUtils.java
Comment thread core/src/main/java/org/apache/cxf/helpers/IOUtils.java
@reta reta requested a review from coheigea July 10, 2026 00:12
@reta reta marked this pull request as ready for review July 10, 2026 00:12
Comment thread core/src/main/java/org/apache/cxf/helpers/IOUtils.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants