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

Refine null-safety for additional Assert methods #33530

Closed
leikingo opened this issue Sep 12, 2024 · 0 comments
Closed

Refine null-safety for additional Assert methods #33530

leikingo opened this issue Sep 12, 2024 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@leikingo
Copy link

leikingo commented Sep 12, 2024

I saw the work being done to add @Contract annotations for null-safety analysis (#32475).

Having a look at the updates to org.springframework.util.Assert methods, I wonder why for example hasText was not annotated with @Contract(null,_ -> fail), although hasText would also throw an exception in case of null.

I'm often using only Assert.hasText for incoming @Nullable strings to ensure a non-null value afterwards. Unfortunately IntelliJ does not recognize this method correctly, like it does for Assert.notNull.

For now I need to add another notNull check in the code or use 'external contract annotations' in IntelliJ, which is quite cumbersome.

It would be great if @Contract annotations could be added to the remaining Assert methods as well to avoid this in the future hoping that they would then also be recognized by IntelliJ correctly).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 12, 2024
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Sep 12, 2024
@sbrannen sbrannen changed the title Refine null-safety for more Assert methods Refine null-safety for additional Assert methods Sep 12, 2024
@sdeleuze sdeleuze self-assigned this Sep 12, 2024
@sdeleuze sdeleuze added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 12, 2024
@sdeleuze sdeleuze modified the milestones: 6.1.14, 6.2.0-RC2 Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants