Skip to content

WebClient.Builder.codecs() is ignored in Spring Boot 2.7.* #34359

@stsypanov

Description

@stsypanov

I use pretty straightforward configuration of my WebClient:

@Configuration
class Config {

    @Value("${client.baseUrl}")
    private String baseUrl;

    @Bean
    public WebClient webClient() {
        return WebClient.builder()
                .codecs(this::configureCodec)
                .baseUrl(baseUrl)
                .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                .build();
    }

    private void configureCodec(ClientCodecConfigurer configurer) {
        configurer
                .defaultCodecs()
                .maxInMemorySize(16 * 1024 * 1024);
    }
}

And it works for spring-boot-starter-parent:2.6.7. However as of spring-boot-starter-parent:2.7.8 for huge payloads I get DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144 which is in turn fixed by adding this line to application.properties:

spring.codec.max-in-memory-size=16777216

Neither ClientCodecConfigurer, nor WebClient.Builder.codecs() are deprecated and their JavaDoc as of 2.7.8 says nothing about spring.codec.max-in-memory-size so this seems to be a bug.

However, if it's not an issue then please provide your answer to https://stackoverflow.com/questions/75445977/is-webclient-builder-codecs-ignored-in-spring-boot-2-7

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions