Skip to content

Allow null to be passed into RabbitProperties.setAddresses #43865

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

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Jan 17, 2025

Before this commit, RabbitProperties cannot be copied when addresses is null.

Before this commit, RabbitProperties cannot be copied when addresses is null.

Signed-off-by: Yanming Zhou <[email protected]>
@mhalbritter mhalbritter changed the title Add defensive check for RabbitProperties to prevent NPE Allow null to be passed into RabbitProperties.setAddresses Jan 17, 2025
@wilkinsona
Copy link
Member

Thanks for the PR, @quaff, but I'm not sure that we should make this change for a couple of reasons:

  1. @ConfigurationProperties classes are not considered to be public API and the binder will never call the setter with null
  2. I suspect there may be other @ConfigurationProperties classes that assume that values passed into setters will not be null

We need to consider 1 and decide if it's something that we want to support. We'd then need to do a review of the codebase to apply any change consistently. I think that's better done as part of #10712. In the meantime, calling code that's chasing to interact with RabbitProperties directly can perform its own null check when mapping the result of getAddresses() on one instance to setAddresses() on another. You could use Boot's PropertyMapper and alwaysApplyingWhenNonNull() to help with that.

@wilkinsona wilkinsona closed this Jan 17, 2025
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants