Skip to content

Commit 0dd6214

Browse files
ryanjbaxterspencergibb
authored andcommitted
Add retryable status code check (spring-projects#197)
* Added API * Add method to check response code retry in the policy.
1 parent fb9e11b commit 0dd6214

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancedRetryPolicy.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,16 @@ public interface LoadBalancedRetryPolicy {
4949
* @param throwable the throwable from the failed execution.
5050
*/
5151
public abstract void registerThrowable(LoadBalancedRetryContext context, Throwable throwable);
52+
53+
/**
54+
* If an exception is not thrown when making a request, than this method will be
55+
* called to see if the client would like to retry the request based on the status
56+
* code returned. For example in CloudFoundry the router will return a <code>404</code>
57+
* when an app is not available. Since HTTP clients do not throw an exception when
58+
* a <code>404</code> is returned than <code>retryableStatusCode</code> allows
59+
* clients to force a retry.
60+
* @param statusCode The HTTP status code.
61+
* @return True if a retry should be attempted, false to just return the response
62+
*/
63+
public boolean retryableStatusCode(int statusCode);
5264
}

0 commit comments

Comments
 (0)