Skip to content

Commit

Permalink
fix(misc): Remove OkHttp2 usage and use provider impls (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
srekapalli committed Oct 3, 2020
1 parent 4118aa5 commit 38415b6
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 209 deletions.
4 changes: 1 addition & 3 deletions echo-rest/echo-rest.gradle
Expand Up @@ -17,9 +17,7 @@
dependencies {
implementation "com.squareup.retrofit:retrofit"
implementation "com.squareup.retrofit:converter-jackson"
implementation "com.squareup.okhttp:okhttp"
implementation "com.squareup.okhttp:okhttp-urlconnection"
implementation "com.squareup.okhttp:okhttp-apache"
implementation "com.jakewharton.retrofit:retrofit1-okhttp3-client"
implementation project(':echo-model')
implementation project(':echo-api')
implementation project(':echo-core')
Expand Down
Expand Up @@ -18,14 +18,17 @@

import static retrofit.Endpoints.newFixedEndpoint;

import com.netflix.spinnaker.echo.rest.RestClientFactory;
import com.jakewharton.retrofit.Ok3Client;
import com.netflix.spinnaker.config.DefaultServiceEndpoint;
import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider;
import com.netflix.spinnaker.echo.rest.RestService;
import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
import okhttp3.OkHttpClient;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -89,9 +92,9 @@ HeadersFromFile headersFromFile() {
@Bean
RestUrls restServices(
RestProperties restProperties,
RestClientFactory clientFactory,
RestAdapter.LogLevel retrofitLogLevel,
RequestInterceptorAttacher requestInterceptorAttacher,
OkHttpClientProvider okHttpClientProvider,
HeadersFromFile headersFromFile) {

RestUrls restUrls = new RestUrls();
Expand All @@ -100,7 +103,13 @@ RestUrls restServices(
RestAdapter.Builder restAdapterBuilder =
new RestAdapter.Builder()
.setEndpoint(newFixedEndpoint(endpoint.getUrl()))
.setClient(clientFactory.getClient(endpoint.insecure))
.setClient(
endpoint.insecure
? new Ok3Client(
okHttpClientProvider.getClient(
new DefaultServiceEndpoint(
endpoint.getEventName(), endpoint.getUrl(), false)))
: new Ok3Client(new OkHttpClient()))
.setLogLevel(retrofitLogLevel)
.setLog(new Slf4jRetrofitLogger(RestService.class))
.setConverter(new JacksonConverter());
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,6 +1,8 @@
package com.netflix.spinnaker.echo.config

import com.netflix.spinnaker.echo.rest.RestClientFactory
import com.netflix.spinnaker.config.okhttp3.InsecureOkHttpClientBuilderProvider
import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider
import okhttp3.OkHttpClient
import retrofit.RequestInterceptor
import retrofit.RestAdapter
import spock.lang.Specification
Expand All @@ -23,7 +25,7 @@ class RestConfigSpec extends Specification {

void configureRestServices(RestProperties.RestEndpointConfiguration endpoint, RestConfig.HeadersFromFile headersFromFile) {
RestProperties restProperties = new RestProperties(endpoints: [endpoint])
config.restServices(restProperties, new RestClientFactory(), config.retrofitLogLevel("BASIC"), attacher, headersFromFile)
config.restServices(restProperties, config.retrofitLogLevel("BASIC"), attacher, new OkHttpClientProvider([new InsecureOkHttpClientBuilderProvider(new OkHttpClient())]), headersFromFile)
}

void "Generate basic auth header"() {
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 38415b6

Please sign in to comment.