Before v5.3.3, when configuring a custom jackson object mapper in WebClient with:
ObjectMapper mapper = instantiateAndConfigureMyCustomObjectMapper();
WebClient client = WebClient.builder().clientConnector(clientConnector)
// ...
.exchangeStrategies(ExchangeStrategies.builder().codecs(configurer -> {
configurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(mapper,
MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));
configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(mapper,
MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));
}).build())
// ...
.build();
when multipart message is being encoded and contains a part with an object subject to be encoded by jackson, the custom mapper was used.
From v5.3.3 onwards, an empty default unconfigured ObjectMapper is used instead, causing several regressions to existing code that expects JSON configuration to be followed.
Most likely changes in spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java are related to this, as it seems now initialization of readers and writer is done eagerly just once instead of on-demand
https://github.com/spring-projects/spring-framework/issues/26263 https://github.com/spring-projects/spring-framework/commit/e1385090e4b008236219bbbf6f5e4d635b4a130b
Comment From: flozano
thanks!