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
Comment From: bclozel
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!
Comment From: hennr
Hi @bclozel,
thanks for the quick reply. I am using the injected builder indeed. A demo repo will be added soon(ish).
Comment From: hennr
...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 👍🏼