Skip to content

Commit

Permalink
fix(retrofit): delete all references to okhttp2.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirangodishala committed Nov 13, 2024
1 parent dbbc628 commit 5e163c2
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jakewharton.retrofit.Ok3Client;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -52,6 +53,7 @@ static void setupOnce() throws Exception {

retrofitService =
new RestAdapter.Builder()
.setClient(new Ok3Client())
.setEndpoint(mockWebServer.url("/").toString())
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())
.build()
Expand Down
2 changes: 1 addition & 1 deletion kork-web/kork-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
api "org.springframework.security:spring-security-core"
api "com.netflix.spectator:spectator-api"
api "com.fasterxml.jackson.core:jackson-annotations"
api "com.squareup.okhttp:okhttp"
// api "com.squareup.okhttp:okhttp"
api "com.squareup.okhttp3:logging-interceptor"
api "com.squareup.okhttp3:okhttp"
api "com.squareup.retrofit:retrofit"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.netflix.spinnaker.kork.crypto.X509IdentitySource;
import com.netflix.spinnaker.okhttp.OkHttp3MetricsInterceptor;
import com.netflix.spinnaker.okhttp.OkHttpClientConfigurationProperties;
import com.netflix.spinnaker.okhttp.OkHttpMetricsInterceptor;
import com.netflix.spinnaker.okhttp.SpinnakerRequestHeaderInterceptor;
import com.netflix.spinnaker.okhttp.SpinnakerRequestInterceptor;
import com.netflix.spinnaker.retrofit.Retrofit2ConfigurationProperties;
Expand Down Expand Up @@ -90,11 +89,6 @@ public SpinnakerRequestHeaderInterceptor spinnakerRequestHeaderInterceptor() {
return new SpinnakerRequestHeaderInterceptor(clientProperties.getPropagateSpinnakerHeaders());
}

@Bean
public OkHttpMetricsInterceptor okHttpMetricsInterceptor() {
return new OkHttpMetricsInterceptor(registryProvider, metricsProperties);
}

@Bean
public OkHttp3MetricsInterceptor okHttp3MetricsInterceptor() {
return new OkHttp3MetricsInterceptor(registryProvider, metricsProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.config.OkHttpMetricsInterceptorProperties;
import com.netflix.spinnaker.kork.common.Header;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
Expand Down Expand Up @@ -45,14 +42,14 @@ protected final Object doIntercept(Object chainObject) throws IOException {
boolean wasSuccessful = false;
int statusCode = -1;

Interceptor.Chain chain =
(chainObject instanceof Interceptor.Chain) ? (Interceptor.Chain) chainObject : null;
// Interceptor.Chain chain =
// (chainObject instanceof Interceptor.Chain) ? (Interceptor.Chain) chainObject : null;
okhttp3.Interceptor.Chain chain3 =
(chainObject instanceof okhttp3.Interceptor.Chain)
? (okhttp3.Interceptor.Chain) chainObject
: null;

Request request = (chain != null) ? chain.request() : null;
// Request request = (chain != null) ? chain.request() : null;
okhttp3.Request request3 = (chain3 != null) ? chain3.request() : null;

List<String> missingHeaders = new ArrayList<>();
Expand All @@ -63,24 +60,24 @@ protected final Object doIntercept(Object chainObject) throws IOException {

Object response;

if (chain != null) {
method = request.method();
url = request.url();
response = chain.proceed(request);
statusCode = ((Response) response).code();
} else {
method = request3.method();
url = request3.url().url();
response = chain3.proceed(request3);
statusCode = ((okhttp3.Response) response).code();
}
// if (chain != null) {
// method = request.method();
// url = request.url();
// response = chain.proceed(request);
// statusCode = ((Response) response).code();
// } else {
method = request3.method();
url = request3.url().url();
response = chain3.proceed(request3);
statusCode = ((okhttp3.Response) response).code();
// }

if (checkForHeaders(url.toString())) {
for (Header header : Header.values()) {
String headerValue =
(request != null)
? request.header(header.getHeader())
: request3.header(header.getHeader());
String headerValue = request3.header(header.getHeader());
// (request != null)
// ? request.header(header.getHeader())
// : request3.header(header.getHeader());

if (header.isRequired() && StringUtils.isEmpty(headerValue)) {
missingHeaders.add(header.getHeader());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import com.netflix.spinnaker.okhttp.OkHttp3MetricsInterceptor;
import com.netflix.spinnaker.okhttp.OkHttpMetricsInterceptor;
// import com.netflix.spinnaker.okhttp.OkHttpMetricsInterceptor;
import com.netflix.spinnaker.okhttp.SpinnakerRequestHeaderInterceptor;
import com.netflix.spinnaker.okhttp.SpinnakerRequestInterceptor;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -47,7 +47,7 @@ void verifyValidConfiguration() {
ctx -> {
assertThat(ctx).hasSingleBean(SpinnakerRequestInterceptor.class);
assertThat(ctx).hasSingleBean(SpinnakerRequestHeaderInterceptor.class);
assertThat(ctx).hasSingleBean(OkHttpMetricsInterceptor.class);
// assertThat(ctx).hasSingleBean(OkHttpMetricsInterceptor.class);
assertThat(ctx).hasSingleBean(OkHttp3MetricsInterceptor.class);
});
}
Expand Down
2 changes: 1 addition & 1 deletion spinnaker-dependencies/spinnaker-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ dependencies {
api("com.squareup.okhttp:mockwebserver:${versions.okhttp}")
api("com.squareup.okhttp:okhttp-apache:${versions.okhttp}")
api("com.squareup.okhttp:okhttp-urlconnection:${versions.okhttp}")
api("com.squareup.okhttp:okhttp:${versions.okhttp}")
// api("com.squareup.okhttp:okhttp:${versions.okhttp}")
api("com.squareup.retrofit2:converter-jackson:${versions.retrofit2}")
api("com.squareup.retrofit2:retrofit-mock:${versions.retrofit2}")
api("com.squareup.retrofit2:retrofit:${versions.retrofit2}")
Expand Down

0 comments on commit 5e163c2

Please sign in to comment.