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

OkHttp RestTemplate adapter uses inappropriate async requests [SPR-13942] #18514

Closed
spring-projects-issues opened this issue Feb 12, 2016 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Kenny MacLeod opened SPR-13942 and commented

OkHttpClientHttpRequestFactory implements both ClientHttpRequestFactory and AsyncClientHttpRequestFactory, but regardless of whether it's called via createRequest or createAsyncRequest it always creates an OkHttpClientHttpRequest, 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 the ClientHttpRequest 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

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

FWIW, Netty has the same "issue" (i.e. async API i used for sync requests), but unlike OkHttp, Netty doesn't have a synchronous API to use instead.

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

PR at #963

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Arjen Poutsma, that approach looks fine to me. Merged into master now.

Juergen

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants