Skip to content

Commit

Permalink
Revert "config(okhttp3): pick up okhttp3 as retrofit client (spinnake…
Browse files Browse the repository at this point in the history
…r#2218)" (spinnaker#2222)

This reverts commit 26b508d.
  • Loading branch information
dreynaud authored May 9, 2018
1 parent 93004b8 commit 22f6ae3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {
group = "com.netflix.spinnaker.orca"

ext {
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.154.1'
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.153.0'
}

def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion]
Expand Down
1 change: 0 additions & 1 deletion orca-retrofit/orca-retrofit.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ dependencies {
spinnaker.group('retrofitDefault')
compile spinnaker.dependency('korkWeb')
compile spinnaker.dependency('rxJava')
compile spinnaker.dependency('retrofit1okHttp3Client')
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

package com.netflix.spinnaker.orca.retrofit

import com.jakewharton.retrofit.Ok3Client
import com.netflix.spinnaker.config.OkHttp3ClientConfiguration
import com.netflix.spinnaker.config.OkHttpClientConfiguration
import com.netflix.spinnaker.orca.retrofit.exceptions.RetrofitExceptionHandler
import com.squareup.okhttp.ConnectionPool
import com.squareup.okhttp.Interceptor
import com.squareup.okhttp.Response
import groovy.transform.CompileStatic
import okhttp3.ConnectionPool
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.beans.factory.annotation.Value
import org.springframework.beans.factory.config.ConfigurableBeanFactory
Expand All @@ -36,41 +34,40 @@ import org.springframework.context.annotation.Scope
import org.springframework.core.Ordered
import org.springframework.core.annotation.Order
import retrofit.RestAdapter.LogLevel

import java.util.concurrent.TimeUnit
import retrofit.client.Client
import retrofit.client.OkClient

@Configuration
@CompileStatic
@Import(OkHttp3ClientConfiguration)
@Import(OkHttpClientConfiguration)
@EnableConfigurationProperties
class RetrofitConfiguration {

@Value('${okHttp3Client.connectionPool.maxIdleConnections:5}')
@Value('${okHttpClient.connectionPool.maxIdleConnections:5}')
int maxIdleConnections

@Value('${okHttp3Client.connectionPool.keepAliveDurationMs:300000}')
@Value('${okHttpClient.connectionPool.keepAliveDurationMs:300000}')
int keepAliveDurationMs

@Value('${okHttp3Client.retryOnConnectionFailure:true}')
@Value('${okHttpClient.retryOnConnectionFailure:true}')
boolean retryOnConnectionFailure

@Bean(name = ["retrofitClient", "okClient"])
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
Ok3Client retrofitClient(@Qualifier("okHttpClientConfiguration") OkHttp3ClientConfiguration okHttpClientConfig) {
OkClient retrofitClient(@Qualifier("okHttpClientConfiguration") OkHttpClientConfiguration okHttpClientConfig) {
final String userAgent = "Spinnaker-${System.getProperty('spring.application.name', 'unknown')}/${getClass().getPackage().implementationVersion ?: '1.0'}"
OkHttpClient.Builder builder = okHttpClientConfig.create()
builder.addNetworkInterceptor(
new Interceptor() {
@Override
Response intercept(Interceptor.Chain chain) throws IOException {
def req = chain.request().newBuilder().header('User-Agent', userAgent).build()
chain.proceed(req)
}
})
.connectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs, TimeUnit.MILLISECONDS))
.retryOnConnectionFailure(retryOnConnectionFailure)
def cfg = okHttpClientConfig.create()
cfg.networkInterceptors().add(new Interceptor() {
@Override
Response intercept(Interceptor.Chain chain) throws IOException {
def req = chain.request().newBuilder().header('User-Agent', userAgent).build()
chain.proceed(req)
}
})
cfg.setConnectionPool(new ConnectionPool(maxIdleConnections, keepAliveDurationMs))
cfg.retryOnConnectionFailure = retryOnConnectionFailure

new Ok3Client(builder.build())
new OkClient(cfg)
}

@Bean LogLevel retrofitLogLevel(@Value('${retrofit.logLevel:BASIC}') String retrofitLogLevel) {
Expand Down

0 comments on commit 22f6ae3

Please sign in to comment.