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

MessageBuilder#createMessage should not define the payload as @Nullable #31610

Closed
herder opened this issue Nov 15, 2023 · 1 comment
Closed
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@herder
Copy link

herder commented Nov 15, 2023

The MessageBuilder#createMessage method has the payload attribute set as @Nullable, but the javadoc and assertions for the method make it clear that passing null as payload is not allowed.

If I understand correctly these annotations were added to make the support for Kotlin and null handling work, but this makes Kotlin expect it to be nullable, which goes against the docs and assertions.

So unless I'm missing something this is a bug and the @Nullable annotation should be removed here?

public static <T> Message<T> createMessage(@Nullable T payload, MessageHeaders messageHeaders) {

@herder herder changed the title [Confusion around @Nullable payload in MessageBuilder Confusion around @Nullable payload in MessageBuilder Nov 15, 2023
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 15, 2023
@snicoll
Copy link
Member

snicoll commented Nov 15, 2023

Thanks for the report. That looks suspicious indeed

@snicoll snicoll changed the title Confusion around @Nullable payload in MessageBuilder MessageBuilder#createMessage should not define the payload as @Nullable Nov 15, 2023
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 15, 2023
@snicoll snicoll self-assigned this Nov 15, 2023
@snicoll snicoll added this to the 6.0.14 milestone Nov 15, 2023
@jhoeller jhoeller added the in: messaging Issues in messaging modules (jms, messaging) label Nov 15, 2023
@snicoll snicoll added the for: backport-to-5.3.x Marks an issue as a candidate for backport to 5.3.x label Nov 15, 2023
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.3.x Marks an issue as a candidate for backport to 5.3.x labels Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants