-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Revise nullability in HttpEntity and ResponseEntity #36238
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refine as suggested for all similar use cases and check with a full build that NullAway does not trigger errors.
|
|
||
| private final HttpHeaders headers; | ||
|
|
||
| private final @Nullable T body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, you should just leverage the nullability defined at type level, so please remove the explicit @Nullable override here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed but the compileJava task build fail
Within @NullMarked, remember, unannotated types are the same as if they were annotated with @nonnull. Since the bound of E is the same as @nonnull Number, and not @nullable Number, that means the type argument for E can't be a type that includes null. @nullable Integer can't be the type argument, then, since that can include null. (In other words: @nullable Integer is not a subtype of Number.)
| * @param headers the entity headers | ||
| * @since 7.0 | ||
| */ | ||
| public HttpEntity(@Nullable T body, @Nullable HttpHeaders headers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, you should just leverage the nullability defined at type level, so please remove the explicit @Nullable override here and in other similar use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DITTO
@Nullable to ResponseEntity generic type
Based on the IDE warning shown in the screenshot
This change adds
@Nullableto the generic bound of ResponseEntity to make the nullability contract.Related to gh-36236