Merge branch '4.0.x'
This commit is contained in:
@@ -50,6 +50,11 @@ public class RetryProperties {
|
||||
*/
|
||||
int maxAttempts = 6;
|
||||
|
||||
/**
|
||||
* Use a random exponential backoff policy.
|
||||
*/
|
||||
boolean useRandomPolicy = false;
|
||||
|
||||
public long getInitialInterval() {
|
||||
return this.initialInterval;
|
||||
}
|
||||
@@ -82,4 +87,12 @@ public class RetryProperties {
|
||||
this.maxAttempts = maxAttempts;
|
||||
}
|
||||
|
||||
public boolean isUseRandomPolicy() {
|
||||
return this.useRandomPolicy;
|
||||
}
|
||||
|
||||
public void setUseRandomPolicy(boolean useRandomPolicy) {
|
||||
this.useRandomPolicy = useRandomPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ public final class RetryTemplateFactory {
|
||||
}
|
||||
|
||||
public static RetryTemplate create(RetryProperties properties, Log log) {
|
||||
RetryTemplate retryTemplate = RetryTemplate.builder().maxAttempts(properties.getMaxAttempts())
|
||||
.exponentialBackoff(properties.getInitialInterval(), properties.getMultiplier(),
|
||||
properties.getMaxInterval())
|
||||
RetryTemplate retryTemplate = RetryTemplate
|
||||
.builder().maxAttempts(properties.getMaxAttempts()).exponentialBackoff(properties.getInitialInterval(),
|
||||
properties.getMultiplier(), properties.getMaxInterval(), properties.isUseRandomPolicy())
|
||||
.build();
|
||||
try {
|
||||
field.set(retryTemplate, log);
|
||||
|
||||
@@ -138,6 +138,7 @@ public class ConfigServerConfigDataLocationResolverTests {
|
||||
assertThat(resource.getRetryProperties().getMaxInterval()).isEqualTo(defaultRetry.getMaxInterval());
|
||||
assertThat(resource.getRetryProperties().getInitialInterval()).isEqualTo(defaultRetry.getInitialInterval());
|
||||
assertThat(resource.getRetryProperties().getMultiplier()).isEqualTo(defaultRetry.getMultiplier());
|
||||
assertThat(resource.getRetryProperties().isUseRandomPolicy()).isEqualTo(defaultRetry.isUseRandomPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,6 +159,7 @@ public class ConfigServerConfigDataLocationResolverTests {
|
||||
assertThat(resource.getRetryProperties().getMaxInterval()).isEqualTo(1500);
|
||||
assertThat(resource.getRetryProperties().getInitialInterval()).isEqualTo(1100);
|
||||
assertThat(resource.getRetryProperties().getMultiplier()).isEqualTo(1.2);
|
||||
assertThat(resource.getRetryProperties().isUseRandomPolicy()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user