Commit 9da71b16 by Ryan Baxter

Removed unnecessary null check and fixed imports

parent ed31004a
......@@ -76,19 +76,12 @@ public class RibbonLoadBalancingHttpClient
final IClientConfig configOverride) throws Exception {
final RequestConfig.Builder builder = RequestConfig.custom();
IClientConfig config = configOverride != null ? configOverride : this.config;
if (config != null) {
builder.setConnectTimeout(config.get(
CommonClientConfigKey.ConnectTimeout, this.connectTimeout));
builder.setSocketTimeout(config.get(
CommonClientConfigKey.ReadTimeout, this.readTimeout));
builder.setRedirectsEnabled(config.get(
CommonClientConfigKey.FollowRedirects, this.followRedirects));
}
else {
builder.setConnectTimeout(this.connectTimeout);
builder.setSocketTimeout(this.readTimeout);
builder.setRedirectsEnabled(this.followRedirects);
}
final RequestConfig requestConfig = builder.build();
......
......@@ -16,15 +16,17 @@
package org.springframework.cloud.netflix.ribbon.okhttp;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
import org.springframework.cloud.netflix.ribbon.support.AbstractLoadBalancingClient;
import org.springframework.web.util.UriComponentsBuilder;
import com.netflix.client.config.CommonClientConfigKey;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.ILoadBalancer;
......@@ -84,7 +86,6 @@ public class OkHttpLoadBalancingClient
OkHttpClient getOkHttpClient(IClientConfig configOverride, boolean secure) {
OkHttpClient.Builder builder = this.delegate.newBuilder();
IClientConfig config = configOverride != null ? configOverride : this.config;
if (config != null) {
builder.connectTimeout(config.get(
CommonClientConfigKey.ConnectTimeout, this.connectTimeout), TimeUnit.MILLISECONDS);
builder.readTimeout(config.get(
......@@ -95,15 +96,6 @@ public class OkHttpLoadBalancingClient
builder.followSslRedirects(configOverride.get(
CommonClientConfigKey.FollowRedirects, this.followRedirects));
}
}
else {
builder.connectTimeout(this.connectTimeout, TimeUnit.MILLISECONDS);
builder.readTimeout(this.readTimeout, TimeUnit.MILLISECONDS);
builder.followRedirects(this.followRedirects);
if (secure) {
builder.followSslRedirects(this.followRedirects);
}
}
return builder.build();
}
......
......@@ -16,6 +16,8 @@
package org.springframework.cloud.netflix.ribbon.okhttp;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import okhttp3.OkHttpClient;
import org.junit.Test;
......@@ -24,12 +26,11 @@ import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.netflix.client.config.CommonClientConfigKey;
import com.netflix.client.config.DefaultClientConfigImpl;
import com.netflix.client.config.IClientConfig;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
/**
* @author Spencer Gibb
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment