Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configured object mapper will be ignored by Spring Cloud Stream 4.1.3 when serialising messages #2977

Closed
wrwksexahatvani opened this issue Jul 24, 2024 · 2 comments

Comments

@wrwksexahatvani
Copy link

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.

@superdanio
Copy link

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 MessageConverters, 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.

@olegz
Copy link
Contributor

olegz commented Aug 15, 2024

This has just been resolved in spring-cloud-function - spring-cloud/spring-cloud-function#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.

ldetmer added a commit to GoogleCloudPlatform/spring-cloud-gcp that referenced this issue Aug 21, 2024
….1.3 failing to deserialize objects (spring-cloud/spring-cloud-stream#2977) causing pubsub steam dead letter test to fail
ldetmer added a commit to GoogleCloudPlatform/spring-cloud-gcp that referenced this issue Aug 21, 2024
….1.3 failing to deserialize objects (spring-cloud/spring-cloud-stream#2977) causing pubsub steam dead letter test to fail
ldetmer added a commit to GoogleCloudPlatform/spring-cloud-gcp that referenced this issue Aug 22, 2024
….1.3 failing to deserialize objects (spring-cloud/spring-cloud-stream#2977) causing pubsub functional sample test to fail
ldetmer added a commit to GoogleCloudPlatform/spring-cloud-gcp that referenced this issue Aug 22, 2024
…est #3139 (#3145)

* fix: Added object mapper bean to fix issue with spring cloud stream 4.1.3 failing to deserialize objects (spring-cloud/spring-cloud-stream#2977) causing pubsub steam dead letter and functional sample test to fail
@olegz olegz closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants