GH-19 SimpleRetryPolicy MaxAttempts JavaDocs

See GH-19
This commit is contained in:
Gary Russell
2014-12-26 11:41:30 -05:00
committed by Dave Syer
parent b5340eb450
commit 660c01adc9
3 changed files with 14 additions and 9 deletions

View File

@@ -156,7 +156,7 @@ The `SimpleRetryPolicy` just allows a retry on any of a named list of exception
```java
SimpleRetryPolicy policy = new SimpleRetryPolicy();
// Set the max retry attempts
// Set the max attempts including the initial attempt before retrying
policy.setMaxAttempts(5);
// Retry on all exceptions (this is the default)
policy.setRetryableExceptions(new Class[] {Exception.class});

View File

@@ -99,7 +99,7 @@ public abstract class RetryInterceptorBuilder<T extends MethodInterceptor> {
/**
* Apply the max attempts - a SimpleRetryPolicy will be used. Cannot be used if a custom retry operations
* or retry policy has been set.
* @param maxAttempts the max attempts.
* @param maxAttempts the max attempts (including the initial attempt).
* @return this.
*/
public RetryInterceptorBuilder<T> maxAttempts(int maxAttempts) {

View File

@@ -92,22 +92,23 @@ public class SimpleRetryPolicy implements RetryPolicy {
}
/**
* Setter for retry attempts.
* Set the number of attempts before retries are exhausted. Includes the initial
* attempt before the retries begin so, generally, will be {@code >= 1}. For example
* setting this property to 3 means 3 attempts total (initial + 2 retries).
*
* @param retryAttempts the number of attempts before a retry becomes
* impossible.
* @param maxAttempts the maximum number of attempts including the initial attempt.
*/
public void setMaxAttempts(int retryAttempts) {
this.maxAttempts = retryAttempts;
public void setMaxAttempts(int maxAttempts) {
this.maxAttempts = maxAttempts;
}
/**
* The maximum number of retry attempts before failure.
* The maximum number of attempts before failure.
*
* @return the maximum number of attempts
*/
public int getMaxAttempts() {
return maxAttempts;
return this.maxAttempts;
}
/**
@@ -118,6 +119,7 @@ public class SimpleRetryPolicy implements RetryPolicy {
* @return true if the last exception was retryable and the number of
* attempts so far is less than the limit.
*/
@Override
public boolean canRetry(RetryContext context) {
Throwable t = context.getLastThrowable();
return (t == null || retryForException(t)) && context.getRetryCount() < maxAttempts;
@@ -126,6 +128,7 @@ public class SimpleRetryPolicy implements RetryPolicy {
/**
* @see org.springframework.retry.RetryPolicy#close(RetryContext)
*/
@Override
public void close(RetryContext status) {
}
@@ -134,6 +137,7 @@ public class SimpleRetryPolicy implements RetryPolicy {
*
* @see RetryPolicy#registerThrowable(RetryContext, Throwable)
*/
@Override
public void registerThrowable(RetryContext context, Throwable throwable) {
SimpleRetryContext simpleContext = ((SimpleRetryContext) context);
simpleContext.registerThrowable(throwable);
@@ -146,6 +150,7 @@ public class SimpleRetryPolicy implements RetryPolicy {
*
* @see org.springframework.retry.RetryPolicy#open(RetryContext)
*/
@Override
public RetryContext open(RetryContext parent) {
return new SimpleRetryContext(parent);
}