Skip to content

Commit

Permalink
GH-19 SimpleRetryPolicy MaxAttempts JavaDocs
Browse files Browse the repository at this point in the history
See GH-19
  • Loading branch information
garyrussell authored and Dave Syer committed Sep 20, 2016
1 parent b5340eb commit 660c01a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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});
Expand Down
Expand Up @@ -99,7 +99,7 @@ public RetryInterceptorBuilder<T> retryOperations(RetryOperations retryOperation
/**
* 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) {
Expand Down
Expand Up @@ -92,22 +92,23 @@ public SimpleRetryPolicy(int maxAttempts, Map<Class<? extends Throwable>, Boolea
}

/**
* 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;
}

/**
Expand All @@ -118,6 +119,7 @@ public int getMaxAttempts() {
* @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;
Expand All @@ -126,6 +128,7 @@ public boolean canRetry(RetryContext context) {
/**
* @see org.springframework.retry.RetryPolicy#close(RetryContext)
*/
@Override
public void close(RetryContext status) {
}

Expand All @@ -134,6 +137,7 @@ public void close(RetryContext status) {
*
* @see RetryPolicy#registerThrowable(RetryContext, Throwable)
*/
@Override
public void registerThrowable(RetryContext context, Throwable throwable) {
SimpleRetryContext simpleContext = ((SimpleRetryContext) context);
simpleContext.registerThrowable(throwable);
Expand All @@ -146,6 +150,7 @@ public void registerThrowable(RetryContext context, Throwable throwable) {
*
* @see org.springframework.retry.RetryPolicy#open(RetryContext)
*/
@Override
public RetryContext open(RetryContext parent) {
return new SimpleRetryContext(parent);
}
Expand Down

0 comments on commit 660c01a

Please sign in to comment.