Closed wrwksexahatvani closed 1 month ago
Just in case this helps anybody else, I've recently come across the same issue, and after some debugging I realised that the SmartCompositeMessageConverter
used behind the scenes was getting initialised by default with a collection of MessageConverter
s, one of which was a org.springframework.cloud.function.context.config.JsonMessageConverter
that used internally its own ObjectMapper
(not getting it from the application context).
I've managed to work around it by defining my own Bean like this:
@Bean
public JsonMessageConverter customJsonMessageConverter(ObjectMapper objectMapper) {
return new JsonMessageConverter(new JacksonMapper(objectMapper));
}
That bean came first within the collection of converters automatically injected in SmartCompositeMessageConverter
and solved the issue for me.
This has just been resolved in spring-cloud-function - https://github.com/spring-cloud/spring-cloud-function/pull/1162 Having said that, the solution from @superdanio is not really a workaround, rather a standard way to extend/change/override something in Spring..
Give i a shot and let me know so we can close it.
Describe the issue Configured object mapper will be ignored when serializing messages leading to a deserialisation error in an integration test.
To Reproduce Build and test https://github.com/andrashatvani/spring-demo/ before and after setting Spring Cloud 2023.0.3 in the POM.
Version of the framework Spring Cloud 2023.0.3
Expected behavior All tests pass.