OkHttp RestTemplate adapter uses inappropriate async requests [SPR-13942] #18514
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Kenny MacLeod opened SPR-13942 and commented
OkHttpClientHttpRequestFactory
implements bothClientHttpRequestFactory
andAsyncClientHttpRequestFactory
, but regardless of whether it's called viacreateRequest
orcreateAsyncRequest
it always creates anOkHttpClientHttpRequest
, which uses OkHttp's async API.There's no obvious issue with this, since calls to the synchronous method of
OkHttpClientHttpRequest
just block until the OkHttp async API returns the goods, but there are scenarios where using the OkHttp async API breaks things, e.g. when the client code is using thread-local-based request interceptors.I suggest that
OkHttpClientHttpRequest
is altered to use the OkHttp sync API when invoked via theClientHttpRequest
interface, and the OkHttp async API when invoked through the {[AsyncClientHttpRequest}} interface.Affects: 4.2.4
Referenced from: pull request #963, and commits e36b753, 37b32d3
The text was updated successfully, but these errors were encountered: