Skip to content

spring.codec.max-in-memory-size does not seem to be honored for JSON decoding #27836

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
hennr opened this issue Aug 30, 2021 · 3 comments
Closed
Labels
status: invalid An issue that we don't feel is valid

Comments

@hennr
Copy link

hennr commented Aug 30, 2021

Hello,

while trying to decode a bigger JSON payload with the following code, I run into the problem that the in memory buffer is too small:

return webClient.get()
            .uri(URI("${githubApiBaseUrl}/repos/$githubGroup/$githubRepo/actions/workflows/$githubWorkflowNameOrId/runs"))
            .retrieve()
            .bodyToMono()

results in:

Caused by: org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144

Setting the config spring.codec.max-in-memory-size to a value of e.g. 1MB does result in the same error.

Only configuring the buffer size programatically does help:

    val webClient = webClientBuilder
        .exchangeStrategies(
        ExchangeStrategies.builder().codecs {
            it.defaultCodecs().maxInMemorySize(1000000)
        }.build()
    )
    .build()

As I am not sure if the property should be honored, I didn't provide a demo project to reproduce the problem.
If this would help, please let me know and I will set up a test project.

related issue: #18828

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 30, 2021
@bclozel
Copy link
Member

bclozel commented Aug 30, 2021

Are you using the pre-configured WebClient.Builder bean provided by Spring Boot? All customizations and defaults are applied to that instance builder. If you start with a vanilla WebClient.create() builder, you'll be getting the Spring Framework defaults.

Something like this:

@Component
public class MyComponent {

  private final WebClient webClient;

  public MyComponent(WebClient.Builder builder) {
    this.webClient = builder.build();
  }

}

If you're indeed using that pattern, could you provide a sample application so that we can reproduce the issue?
Thanks!

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Aug 30, 2021
@hennr
Copy link
Author

hennr commented Aug 30, 2021

Hi @bclozel,

thanks for the quick reply. I am using the injected builder indeed. A demo repo will be added soon(ish).

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 30, 2021
@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Aug 30, 2021
@hennr
Copy link
Author

hennr commented Aug 30, 2021

...I am using the injected builder indeed.

In the production code at least, but not in my test code. argh
My test adds a WebClient.builder() to the service's constructor, so there we have it.

Sorry for bothering and keep up your nice work 👍🏼

@hennr hennr closed this as completed Aug 30, 2021
@bclozel bclozel added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants