Skip to content

Commit

Permalink
fix(retrofit): remove all references to com.squareup.okhttp (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirangodishala authored Nov 15, 2024
1 parent dbbc628 commit 27db630
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 196 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
1 change: 0 additions & 1 deletion kork-web/kork-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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.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,11 @@ 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;
okhttp3.Interceptor.Chain chain3 =
(chainObject instanceof okhttp3.Interceptor.Chain)
? (okhttp3.Interceptor.Chain) chainObject
: 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 +57,14 @@ 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();
}
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());

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,6 @@
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.SpinnakerRequestHeaderInterceptor;
import com.netflix.spinnaker.okhttp.SpinnakerRequestInterceptor;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -47,7 +46,6 @@ void verifyValidConfiguration() {
ctx -> {
assertThat(ctx).hasSingleBean(SpinnakerRequestInterceptor.class);
assertThat(ctx).hasSingleBean(SpinnakerRequestHeaderInterceptor.class);
assertThat(ctx).hasSingleBean(OkHttpMetricsInterceptor.class);
assertThat(ctx).hasSingleBean(OkHttp3MetricsInterceptor.class);
});
}
Expand Down
5 changes: 0 additions & 5 deletions spinnaker-dependencies/spinnaker-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ext {
// 1.4.14. See https://logback.qos.ch/news.html#1.3.12.
logback : "1.2.13",
protobuf : "3.25.2",
okhttp : "2.7.5", // CVE-2016-2402
okhttp3 : "4.9.3",
openapi : "1.3.9", // this needs to be kept in sync with spring boot as it pulls in the spring-boot-dependencies BOM
restassured : "5.2.1", // spring boot 2.7.18 brings rest-assured 4.5.1. It uses groovy 3. Keep until spring boot >=3.0.13
Expand Down Expand Up @@ -140,10 +139,6 @@ dependencies {
api("com.squareup.okhttp3:okhttp-sse:${versions.okhttp3}")
api("com.squareup.okhttp3:okhttp-urlconnection:${versions.okhttp3}")
api("com.squareup.okhttp3:okhttp:${versions.okhttp3}")
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.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 27db630

Please sign in to comment.