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

Default configuration of AbstractMessageChannelMessagingSendingTemplate leads to Jackson error: "Could not write JSON: Java 8 date/time type java.time.Instant not supported by default" #407

Closed
zachzientek opened this issue Jun 6, 2022 · 3 comments
Labels
component: sns SNS integration related issue status: waiting-for-feedback Waiting for feedback from issuer type: question Further information is requested

Comments

@zachzientek
Copy link

Type: Bug

Component: SNS

Describe the bug
Using Spring Cloud AWS 2.4.1, Spring Cloud 2021.0.2, and Spring Boot 2.7.0.
This issue is similar to a previous issue with SQS (#217) but occurs when trying to send SNS messages (NotificationMessagingTemplate.convertAndSend) that contains fields of Java date/time types. It leads to the following Jackson error:
"Could not write JSON: Java 8 date/time type java.time.Instant not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling". Adding JSR310 dependency to the classpath does not resolve this issue.

@github-actions github-actions bot added component: sns SNS integration related issue type: bug Something isn't working status: waiting-for-triage Team has not yet looked into this issue labels Jun 6, 2022
@maciejwalkowiak
Copy link
Contributor

When creating NotificationMessagingTemplate, you can pass custom MessageConverter which can be an instance of MappingJackson2MessageConverter configured with ObjectMapper supporting JSR 310 modules.

@maciejwalkowiak maciejwalkowiak added status: waiting-for-feedback Waiting for feedback from issuer type: question Further information is requested and removed status: waiting-for-triage Team has not yet looked into this issue type: bug Something isn't working labels Jun 7, 2022
@zachzientek
Copy link
Author

Thanks for the feedback. Yeah, I figured out the workaround as you mentioned. I wasn't sure if it was intentional that the Spring configured ObjectMapper wasn't being used and especially that Java 8 time support isn't included by default.

@maciejwalkowiak
Copy link
Contributor

Thanks for coming back.

In 3.0 SNS auto-configuration creates SnsTemplate with provided ObjectMapper (https://github.com/awspring/spring-cloud-aws/blob/main/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/sns/SnsAutoConfiguration.java#L71). We do not have plans to change that for 2.4.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sns SNS integration related issue status: waiting-for-feedback Waiting for feedback from issuer type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants