Commit b9a6876d by Spencer Gibb

Upgrade ribbon to 2.1.3

fixes gh-908
parent f76675a5
...@@ -54,13 +54,24 @@ public class LoadBalancerFeignClient implements Client { ...@@ -54,13 +54,24 @@ public class LoadBalancerFeignClient implements Client {
new FeignOptionsClientConfig(options)).toResponse(); new FeignOptionsClientConfig(options)).toResponse();
} }
catch (ClientException e) { catch (ClientException e) {
if (e.getCause() instanceof IOException) { IOException io = findIOException(e);
throw IOException.class.cast(e.getCause()); if (io != null) {
throw io;
} }
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
protected IOException findIOException(Throwable t) {
if (t == null) {
return null;
}
if (t instanceof IOException) {
return (IOException) t;
}
return findIOException(t.getCause());
}
public Client getDelegate() { public Client getDelegate() {
return this.delegate; return this.delegate;
} }
......
...@@ -16,26 +16,18 @@ ...@@ -16,26 +16,18 @@
package org.springframework.cloud.netflix.feign.ribbon; package org.springframework.cloud.netflix.feign.ribbon;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.netflix.ribbon.RibbonClient;
...@@ -44,7 +36,6 @@ import org.springframework.context.annotation.Bean; ...@@ -44,7 +36,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -52,15 +43,23 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -52,15 +43,23 @@ import org.springframework.web.bind.annotation.RestController;
import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.Server;
import com.netflix.loadbalancer.ServerList; import com.netflix.loadbalancer.ServerList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/** /**
* Tests the Feign Retryer, not ribbon retry.
* @author Spencer Gibb * @author Spencer Gibb
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = FeignRibbonClientRetryTests.Application.class) @SpringApplicationConfiguration(classes = FeignRibbonClientRetryTests.Application.class)
@WebAppConfiguration @WebIntegrationTest(randomPort = true, value = { "spring.application.name=feignclientretrytest",
@IntegrationTest({ "server.port=0", "spring.application.name=feignclienttest", "feign.okhttp.enabled=false", "feign.httpclient.enabled=false",
"localapp.ribbon.MaxAutoRetries=5", "localapp.ribbon.MaxAutoRetriesNextServer=5", "feign.hystrix.enabled=false", })
"localapp.ribbon.OkToRetryOnAllOperations=true", })
@DirtiesContext @DirtiesContext
public class FeignRibbonClientRetryTests { public class FeignRibbonClientRetryTests {
...@@ -70,14 +69,13 @@ public class FeignRibbonClientRetryTests { ...@@ -70,14 +69,13 @@ public class FeignRibbonClientRetryTests {
@Autowired @Autowired
private TestClient testClient; private TestClient testClient;
// @FeignClient(value = "http://localhost:9876", loadbalance = false)
@FeignClient("localapp") @FeignClient("localapp")
protected static interface TestClient { protected interface TestClient {
@RequestMapping(method = RequestMethod.GET, value = "/hello") @RequestMapping(method = RequestMethod.GET, value = "/hello")
public Hello getHello(); Hello getHello();
@RequestMapping(method = RequestMethod.GET, value = "/retryme") @RequestMapping(method = RequestMethod.GET, value = "/retryme")
public int retryMe(); int retryMe();
} }
@Configuration @Configuration
...@@ -101,12 +99,8 @@ public class FeignRibbonClientRetryTests { ...@@ -101,12 +99,8 @@ public class FeignRibbonClientRetryTests {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
new SpringApplicationBuilder(Application.class).properties( new SpringApplicationBuilder(Application.class).properties(
"spring.application.name=feignclienttest", "spring.application.name=feignclientretrytest",
"localapp.ribbon.MaxAutoRetries=5",
"localapp.ribbon.MaxAutoRetriesNextServer=5",
"localapp.ribbon.OkToRetryOnAllOperations=true",
"management.contextPath=/admin" "management.contextPath=/admin"
// ,"local.server.port=9999"
).run(args); ).run(args);
} }
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<eureka.version>1.4.4</eureka.version> <eureka.version>1.4.4</eureka.version>
<feign.version>8.15.1</feign.version> <feign.version>8.15.1</feign.version>
<hystrix.version>1.5.1</hystrix.version> <hystrix.version>1.5.1</hystrix.version>
<ribbon.version>2.1.1</ribbon.version> <ribbon.version>2.1.3</ribbon.version>
<servo.version>0.10.1</servo.version> <servo.version>0.10.1</servo.version>
<zuul.version>1.1.0</zuul.version> <zuul.version>1.1.0</zuul.version>
<rxjava.version>1.1.1</rxjava.version> <rxjava.version>1.1.1</rxjava.version>
......
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