Skip to content

Commit

Permalink
Adding missing commit from PR #1457
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Baxter committed Feb 9, 2017
1 parent c6a3157 commit 0af9976
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ public Feign.Builder feignHystrixBuilder() {
}
}

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ public RibbonResponse execute(final RibbonRequest request, IClientConfig configO
}
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) {
Expand All @@ -120,19 +122,6 @@ public RibbonResponse doWithRetry(RetryContext retryContext) throws IOException
@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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void overrideLoggerLevel() {

@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));
}

Expand Down

0 comments on commit 0af9976

Please sign in to comment.