-
Notifications
You must be signed in to change notification settings - Fork 173
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
feat(retrofit2): Improvise OkHttpClientProvider to accept interceptors #1220
feat(retrofit2): Improvise OkHttpClientProvider to accept interceptors #1220
Conversation
ObjectMapper objectMapper, | ||
List<Interceptor> interceptors) { | ||
// retrofit1 doesn't support okhttp3.Interceptor. This method override is just to fulfill the | ||
// contract. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safer to throw an exception here if interceptors isn't empty?
Class<T> type, | ||
ServiceEndpoint serviceEndpoint, | ||
ObjectMapper objectMapper, | ||
List<Interceptor> interceptors); // This is supported only by Retrofit2ServiceFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this comment will get stale over time.
We could use some test coverage for the new methods. |
…tProvider to support list of interceptors.
78b1111
to
8e409c1
Compare
As an alternate to using
OkHttp3ClientConfiguration
for creating an OkHttpClient,OkHttpClientProvider
was created through#639. But there are many existing retrofit clients that are passing Interceptor(s) which is not supported by
OkHttpClientProvider
. This PR allowsOkHttpClientProvider
to acceptokhttp3.Interceptor
list.As we are slowly moving to retrofit2(rosco completed, echo under review), the real consumer of OkHttpClientProvider will be
Retrofit2ServiceFactory
(as opposed toRetrofitServiceFactory
) but since it's an implementation ofServiceClientFactory
, I had to add a method that takesList<Interceptor>
which is specific toRetrofit2ServiceFactory
and hence the method has no significance wrtRetrofitServiceFactory
.The idea is to use
OkHttpClientProvider
instead ofOkHttp3ClientConfiguration
while upgrading the http clients from retrofit1 to retrofit2.