Skip to content

Support for limits on input stream processing in WebFlux codecs #23884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rstoyanchev opened this issue Oct 29, 2019 · 3 comments
Closed

Support for limits on input stream processing in WebFlux codecs #23884

rstoyanchev opened this issue Oct 29, 2019 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@rstoyanchev
Copy link
Contributor

While a proxy, or the underlying server, or a WebFilter can be used to enforce general limits on the size of server request input, it would be helpful for Decoder and HttpMessageReader implementations to expose configurable limits too, because codecs in WebFlux can parse asynchronously and pass one object one at a time to the application, as a stream. That means the overall request input stream may be infinite, and it's the input per streamed object that should be limited.

@rstoyanchev rstoyanchev self-assigned this Oct 29, 2019
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Oct 29, 2019
@rstoyanchev rstoyanchev added this to the 5.2.1 milestone Oct 29, 2019
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.1.x labels Oct 29, 2019
rstoyanchev added a commit that referenced this issue Oct 29, 2019
- Add maxInMemorySize property to Decoder and HttpMessageReader
  implementations that aggregate input to trigger
  DataBufferLimitException when reached.

- For codecs that call DataBufferUtils#join, there is now an overloaded
  variant with a maxInMemorySize extra argument. Internally, a custom
  LimitedDataBufferList is used to count and enforce the limit.

- Jackson2Tokenizer and XmlEventDecoder support those limits per
  streamed JSON object.

See gh-23884
rstoyanchev pushed a commit that referenced this issue Oct 29, 2019
rstoyanchev added a commit that referenced this issue Oct 29, 2019
rstoyanchev added a commit that referenced this issue Oct 29, 2019
- Add maxInMemorySize property to Decoder and HttpMessageReader
  implementations that aggregate input to trigger
  DataBufferLimitException when reached.

- For codecs that call DataBufferUtils#join, there is now an overloaded
  variant with a maxInMemorySize extra argument. Internally, a custom
  LimitedDataBufferList is used to count and enforce the limit.

- Jackson2Tokenizer and XmlEventDecoder support those limits per
  streamed JSON object.

- Configurable limits for multipart requests with Synchronoss NIO.

- Centralized maxInMemorySize exposed via CodecConfigurer along with
  ability to plug in an instance of MultipartHttpMessageWrite.

Closes gh-23884
@rstoyanchev
Copy link
Contributor Author

rstoyanchev commented Oct 29, 2019

For an overview see "Limits" section in the reference documentation.

bclozel added a commit that referenced this issue Oct 30, 2019
bclozel added a commit that referenced this issue Oct 30, 2019
pull bot pushed a commit to scope-demo/spring-framework that referenced this issue Oct 30, 2019
@scottjohnson
Copy link

I know this issue was closed in October, but I'm curious @rstoyanchev if you could explain what the downside of not having a limit is? In other words prior to implementing the limit, what could go wrong if the size was very large and how would that manifest; such that adding a limit by default is an effective protection?

@rstoyanchev
Copy link
Contributor Author

@scottjohnson there is some explanation in the docs. It's about making it easy for applications to declare limits on input buffering. In the absence of such limits the application can run out of memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants