Refine null-safety for additional Assert
methods
#33530
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
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 examplehasText
was not annotated with@Contract(null,_ -> fail)
, althoughhasText
would also throw an exception in case ofnull
.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 forAssert.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 remainingAssert
methods as well to avoid this in the future hoping that they would then also be recognized by IntelliJ correctly).The text was updated successfully, but these errors were encountered: