Description
The retrieve()
workflow in RestClient
splits the exchange over two method calls. The call to retrieve()
executes the request but doesn't extract, and the subsequent call to one of the ResponseSpec
methods actually extracts the response.
This makes sense but it's also reasonable to conclude you can just call retrieve()
if you don't care for the response. In that case, however, the observation scope remains open, the status is not checked, and the connection is not closed.
retrieve()
should merely a step towards fully declaring the exchange before, and only once a ResponseSpec
method is selected should we proceed with execution and response extraction. Same way it works with the RestTemplate.
This will make the retrieve()
workflow a true shortcut for calling exchange()
, fully scoped within a call to exchange()
with a built-in ExchangeFunction
based on the ResponseSpec
selection. If an application actually wants to split execution and extraction into separate steps, it can use the exchange
variants.