Commit 0af99769 by Ryan Baxter

Adding missing commit from PR #1457

parent c6a3157f
......@@ -105,10 +105,16 @@ public class FeignClientsConfiguration {
}
@Bean
@ConditionalOnMissingBean
public Retryer feignRetryer() {
return Retryer.NEVER_RETRY;
}
@Bean
@Scope("prototype")
@ConditionalOnMissingBean
public Feign.Builder feignBuilder() {
return Feign.builder().retryer(Retryer.NEVER_RETRY);
public Feign.Builder feignBuilder(Retryer retryer) {
return Feign.builder().retryer(retryer);
}
@Bean
......
......@@ -97,11 +97,13 @@ public class FeignLoadBalancer extends
}
LoadBalancedRetryPolicy retryPolicy = loadBalancedRetryPolicyFactory.create(this.getClientName(), this);
retryTemplate.setRetryPolicy(retryPolicy == null ? new NeverRetryPolicy()
: new InterceptorRetryPolicy(request.toHttpRequest(), retryPolicy, this, this.getClientName()));
: new FeignRetryPolicy(request.toHttpRequest(), retryPolicy, this, this.getClientName()));
return retryTemplate.execute(new RetryCallback<RibbonResponse, IOException>() {
@Override
public RibbonResponse doWithRetry(RetryContext retryContext) throws IOException {
Request feignRequest = null;
//on retries the policy will choose the server and set it in the context
// extract the server and update the request being made
if(retryContext instanceof LoadBalancedRetryContext) {
ServiceInstance service = ((LoadBalancedRetryContext)retryContext).getServiceInstance();
if(service != null) {
......@@ -120,19 +122,6 @@ public class FeignLoadBalancer extends
@Override
public RequestSpecificRetryHandler getRequestSpecificRetryHandler(
RibbonRequest request, IClientConfig requestConfig) {
// if (this.clientConfig.get(CommonClientConfigKey.OkToRetryOnAllOperations,
// false)) {
// return new RequestSpecificRetryHandler(true, true, this.getRetryHandler(),
// requestConfig);
// }
// if (!request.toRequest().method().equals("GET")) {
// return new RequestSpecificRetryHandler(true, false, this.getRetryHandler(),
// requestConfig);
// }
// else {
// return new RequestSpecificRetryHandler(true, true, this.getRetryHandler(),
// requestConfig);
// }
return new RequestSpecificRetryHandler(false, false, this.getRetryHandler(), requestConfig);
}
......
......@@ -108,7 +108,7 @@ public class FeignClientOverrideDefaultsTests {
@Test
public void overrideRetryer() {
assertNull(this.context.getInstance("foo", Retryer.class));
assertEquals(Retryer.NEVER_RETRY, this.context.getInstance("foo", Retryer.class));
Retryer.Default.class.cast(this.context.getInstance("bar", Retryer.class));
}
......
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