admin管理员组文章数量:1389873
when migrating from spring 6.1.5 to spring 6.2.3 I noticed in the RestClient interface that the the exchange method is now nullable. link to docs
How could you end up in a situation where Restclient returns null? Is the correct pattern now to have a default response when null is returned?
when migrating from spring 6.1.5 to spring 6.2.3 I noticed in the RestClient interface that the the exchange method is now nullable. link to docs
How could you end up in a situation where Restclient returns null? Is the correct pattern now to have a default response when null is returned?
Share Improve this question asked Mar 12 at 16:11 user406955user406955 891 silver badge11 bronze badges1 Answer
Reset to default 0By default, RestClient's retrieve()
never returns null
as it only proceeds to the declaration of how the response will be handled. The subsequently called methods body()
or exchange()
perform the call, and they return null
depending on the situation:
body()
returnsnull
if there is simply no response body available. A good example is HTTP204 NO CONTENT
status code.exchange()
returnsnull
ifExchangeFunction
returns it as well. You are in charge of its implementation by saying what happens with the response (also the request) is available. If your implementation returnsnull
, you got it.
The only explanation that makes sense to me is that the method contract documentation and annotation were fixed.
本文标签: javaSpring Restclientexchange null response handling in spring 623Stack Overflow
版权声明:本文标题:java - Spring Restclient.exchange null response handling in spring 6.2.3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744741333a2622625.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论