Skip to content

JSON message converter returns null for empty POJO #1097

Closed
@castelblanque

Description

@castelblanque

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:

  1. Create POJO class e.g.
    public class EmptyPOJO {
    }
  2. Use JsonMessageConverter#convertToInternal method to convert the POJO. It uses jsonMapper.toJson(payload) inside.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions