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

feat(retrofit2): Improvise OkHttpClientProvider to accept interceptors #1220

Merged

Conversation

kirangodishala
Copy link
Contributor

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 allows OkHttpClientProvider to accept okhttp3.Interceptor list.

As we are slowly moving to retrofit2(rosco completed, echo under review), the real consumer of OkHttpClientProvider will be Retrofit2ServiceFactory(as opposed to RetrofitServiceFactory) but since it's an implementation of ServiceClientFactory, I had to add a method that takes List<Interceptor> which is specific to Retrofit2ServiceFactory and hence the method has no significance wrt RetrofitServiceFactory.

The idea is to use OkHttpClientProvider instead of OkHttp3ClientConfiguration while upgrading the http clients from retrofit1 to retrofit2.

ObjectMapper objectMapper,
List<Interceptor> interceptors) {
// retrofit1 doesn't support okhttp3.Interceptor. This method override is just to fulfill the
// contract.
Copy link
Contributor

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
Copy link
Contributor

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.

@dbyron-sf
Copy link
Contributor

We could use some test coverage for the new methods.

@kirangodishala kirangodishala force-pushed the improvise-okhttpclientprovider branch from 78b1111 to 8e409c1 Compare January 9, 2025 13:34
@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Jan 9, 2025
@mergify mergify bot added the auto merged label Jan 9, 2025
@mergify mergify bot merged commit b4097e5 into spinnaker:master Jan 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged ready to merge Approved and ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants