Skip to content

Remove TODO comment and unnecessary null checks for getBeanName()#4253

Merged
artembilan merged 1 commit intospring-projects:mainfrom
david-parkk:fix/getBeanName-nonnull-annotation
Jan 20, 2026
Merged

Remove TODO comment and unnecessary null checks for getBeanName()#4253
artembilan merged 1 commit intospring-projects:mainfrom
david-parkk:fix/getBeanName-nonnull-annotation

Conversation

@david-parkk
Copy link
Contributor

Summary

This PR attempts to resolve the TODO comment in AbstractMessageListenerContainer.getBeanName() by adding @NonNull annotation and removing what appear to be unnecessary null checks in related classes.

Analysis

Based on my understanding of the codebase:

  • The beanName field is declared as @NonNull with default value "noBeanNameSet"
  • Therefore, getBeanName() should never return null
  • The original @Nullable annotation seems to have been incorrect
  • The null checks (getBeanName() == null ? "" : getBeanName()) appear to be unnecessary

Please let me know if I've misunderstood any aspect of this.

Changes

  • AbstractMessageListenerContainer.java: Remove TODO comment, add @NonNull to getBeanName()
  • KafkaMessageListenerContainer.java: Remove unnecessary null check
  • ShareKafkaMessageListenerContainer.java: Remove unnecessary null check

Test

Added shouldSupportDefaultBeanNameSetting() test to verify that getBeanName() returns the default value "noBeanNameSet" instead of null when setBeanName() is not called.


I'm happy to make any adjustments based on your feedback. Thank you to the maintainers for taking the time to review this contribution!

@david-parkk
Copy link
Contributor Author

I removed the @NonNull from the method since the field already has @NonNull annotation - adding it to the getter seemed redundant. Happy to add it back if you prefer explicit annotation on the method.

@david-parkk david-parkk changed the title Add @NonNull to getBeanName() and remove unnecessary null checks Remove TODO comment and unnecessary null checks for getBeanName() Jan 18, 2026
Signed-off-by: david-parkk <ji0513ji@naver.com>
@david-parkk david-parkk force-pushed the fix/getBeanName-nonnull-annotation branch from 9e0ef68 to 8816596 Compare January 18, 2026 15:30
@artembilan artembilan added this to the 4.0.2 milestone Jan 20, 2026
@artembilan artembilan enabled auto-merge (squash) January 20, 2026 16:52
@artembilan
Copy link
Member

Thank you!
Will be merged after successful build.

@artembilan artembilan merged commit 2ca9c72 into spring-projects:main Jan 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants