spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.77k stars 38.16k forks source link

Introduce `@CheckReturnValue` annotation #33818

Closed rstoyanchev closed 1 month ago

rstoyanchev commented 1 month ago

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.