Add @Nullable to ResponseEntity generic type#36238
Open
ngocnhan-tran1996 wants to merge 1 commit intospring-projects:mainfrom
Open
Add @Nullable to ResponseEntity generic type#36238ngocnhan-tran1996 wants to merge 1 commit intospring-projects:mainfrom
@Nullable to ResponseEntity generic type#36238ngocnhan-tran1996 wants to merge 1 commit intospring-projects:mainfrom
Conversation
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
sdeleuze
requested changes
Feb 5, 2026
|
|
||
| private final HttpHeaders headers; | ||
|
|
||
| private final @Nullable T body; |
Contributor
There was a problem hiding this comment.
Here, you should just leverage the nullability defined at type level, so please remove the explicit @Nullable override here.
| * @param headers the entity headers | ||
| * @since 7.0 | ||
| */ | ||
| public HttpEntity(@Nullable T body, @Nullable HttpHeaders headers) { |
Contributor
There was a problem hiding this comment.
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.
| * @since 4.1 | ||
| */ | ||
| public static <T> ResponseEntity<T> ok(@Nullable T body) { | ||
| public static <T extends @Nullable Object> ResponseEntity<T> ok(@Nullable T body) { |
Contributor
There was a problem hiding this comment.
Here I think you should just use public static <T> ResponseEntity<T> ok(T body) since the nullability is defined at type level. Please adapt similar use cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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