After I've updated to spring-boot 2.3.0 (so my webflux WebClient is now from version 5.2.6) custom ObjectMapper is completely ignored. My configuration looks as follows
public static WebClient buildWebClient(WebClient.Builder builder) {
return builder
.defaultHeader(ACCEPT, APPLICATION_JSON_VALUE)
.defaultHeader(HttpHeaders.ACCEPT_ENCODING, "identity")
.exchangeStrategies(ExchangeStrategies
.builder()
.codecs(codecConfigurer -> {
codecConfigurer.defaultCodecs().jackson2JsonDecoder(buildJsonDeserializer());
})
.build())
.build();
}
public static Jackson2JsonDecoder buildJsonDeserializer() {
ObjectMapper customObjectMapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addDeserializer(Map.class, new JsonDeserializer<Map<String, String>>() {
@Override
public Map<String, String> deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException {
...
}
});
customObjectMapper.registerModule(simpleModule);
return new Jackson2JsonDecoder(customObjectMapper, MediaType.APPLICATION_JSON);
}
There is bug in new version or it's just something that have changed and I don't know how to set it now?