Closed
Description
Describe the issue
When using an empty POJO (class without fields), JsonMessageConverter
converts it to null instead of a representation of an empty JSON ({}
).
To Reproduce
Steps to reproduce the behavior:
- Create POJO class e.g.
public class EmptyPOJO { }
- Use
JsonMessageConverter#convertToInternal
method to convert the POJO. It usesjsonMapper.toJson(payload)
inside. - Returned value is
null
Version of the framework
Spring Cloud Stream 4.0.4
Expected behavior
JSON message converter returns the representation of an empty JSON: {}
Additional context
Issue appeared when migrating from Spring Boot 2 to 3.0.12. Stream tests that we had passing in v2 started to fail, and we debugged the problem down to this issue.