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

Introduce @CheckReturnValue annotation #33818

Closed
rstoyanchev opened this issue Oct 30, 2024 · 0 comments
Closed

Introduce @CheckReturnValue annotation #33818

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

Comments

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Oct 30, 2024

After #33777, the retrieve() method in RestClient no longer executes, and instead expects one of the ResponseSpec methods to be called. It is possible that some applications rely on the current behavior, for example if they don't care for the actual response as long as it is not an error. However, using the ResponseSpec is and was expected to avoid other side effects.

We should add a @CheckReturnValue annotation for this and other similar API cases that would allow IDE's to warn about not using the return value, along side the @Contract annotation added in #32475.

@rstoyanchev rstoyanchev added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Oct 30, 2024
@rstoyanchev rstoyanchev added this to the 6.2.0 milestone Oct 30, 2024
@sdeleuze sdeleuze self-assigned this Oct 30, 2024
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Oct 30, 2024
This commit introduces a `@CheckReturnValue` annotation,
inspired from org.jetbrains.annotations.CheckReturnValue,
that specifies that the method return value must be used.

See spring-projectsgh-33818
@sdeleuze sdeleuze changed the title Add @CheckReturnValue annotation Introduce @CheckReturnValue annotation Oct 30, 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

2 participants