More Javadoc polishing: ExponentialBackOffPolicy

Resolves https://github.com/spring-projects/spring-retry/issues/210
This commit is contained in:
Gary Russell
2020-08-25 11:15:44 -04:00
parent f25d6e8ff4
commit 71744ee8cb
2 changed files with 12 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ import org.springframework.util.ClassUtils;
/**
* Implementation of {@link BackOffPolicy} that increases the back off period for each
* retry attempt in a given set using the {@link Math#exp(double) exponential} function.
* retry attempt in a given set up to a limit.
*
* This implementation is thread-safe and suitable for concurrent access. Modifications to
* the configuration do not affect any retry sets that are already in progress.
@@ -61,7 +61,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy<Exponenti
public static final double DEFAULT_MULTIPLIER = 2;
/**
* The initial sleep interval.
* The initial backoff interval.
*/
private volatile long initialInterval = DEFAULT_INITIAL_INTERVAL;
@@ -71,7 +71,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy<Exponenti
private volatile long maxInterval = DEFAULT_MAX_INTERVAL;
/**
* The value to increment the exp seed with for each retry attempt.
* The value to add to the backoff period for each retry attempt.
*/
private volatile double multiplier = DEFAULT_MULTIPLIER;
@@ -158,8 +158,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy<Exponenti
}
/**
* Returns a new instance of {@link BackOffContext} configured with the 'expSeed' and
* 'increment' values.
* Returns a new instance of {@link BackOffContext} with the configured properties.
*/
@Override
public BackOffContext start(RetryContext context) {
@@ -167,7 +166,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy<Exponenti
}
/**
* Pause for a length of time equal to ' <code>exp(backOffContext.expSeed)</code>'.
* Pause for the current backoff interval.
*/
@Override
public void backOff(BackOffContext backOffContext) throws BackOffInterruptedException {
@@ -192,8 +191,8 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy<Exponenti
private long maxInterval;
public ExponentialBackOffContext(long expSeed, double multiplier, long maxInterval) {
this.interval = expSeed;
public ExponentialBackOffContext(long interval, double multiplier, long maxInterval) {
this.interval = interval;
this.multiplier = multiplier;
this.maxInterval = maxInterval;
}

View File

@@ -14,6 +14,7 @@ public class CircuitBreakerResetTimeoutTest {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
CircuitBreakerResetTimeoutTest.TestConfiguration.class);
private TestService serviceInTest = context.getBean(TestService.class);
@Test
@@ -57,10 +58,12 @@ public class CircuitBreakerResetTimeoutTest {
@Configuration
@EnableRetry
protected static class TestConfiguration {
@Bean
public TestService externalService() {
return new TestService();
}
}
static class TestService {
@@ -71,7 +74,7 @@ public class CircuitBreakerResetTimeoutTest {
String service(String payload) {
this.context = RetrySynchronizationManager.getContext();
System.out.println("real service called");
if(payload.contentEquals("FAIL")) {
if (payload.contentEquals("FAIL")) {
throw new RuntimeException("");
}
return payload;
@@ -86,6 +89,7 @@ public class CircuitBreakerResetTimeoutTest {
public RetryContext getContext() {
return this.context;
}
}
}