mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-29 02:39:04 +00:00
Allow FixedBackOff to be constructed with only a custom interval
This commit introduces two new constructors: - FixedBackOff(long) - FixedBackOff(Duration) Closes gh-35028
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.core.retry;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.retry.support.MaxRetryAttemptsPolicy;
|
||||
@@ -55,7 +57,7 @@ class RetryTemplateTests {
|
||||
}
|
||||
};
|
||||
|
||||
retryTemplate.setBackOffPolicy(new FixedBackOff(100, Long.MAX_VALUE));
|
||||
retryTemplate.setBackOffPolicy(new FixedBackOff(Duration.ofMillis(10)));
|
||||
|
||||
assertThat(retryTemplate.execute(retryable)).isEqualTo("hello world");
|
||||
}
|
||||
@@ -76,7 +78,7 @@ class RetryTemplateTests {
|
||||
}
|
||||
};
|
||||
|
||||
retryTemplate.setBackOffPolicy(new FixedBackOff(100, Long.MAX_VALUE));
|
||||
retryTemplate.setBackOffPolicy(new FixedBackOff(Duration.ofMillis(10)));
|
||||
|
||||
assertThatExceptionOfType(RetryException.class)
|
||||
.isThrownBy(() -> retryTemplate.execute(retryable))
|
||||
@@ -123,7 +125,7 @@ class RetryTemplateTests {
|
||||
}
|
||||
};
|
||||
retryTemplate.setRetryPolicy(retryPolicy);
|
||||
retryTemplate.setBackOffPolicy(new FixedBackOff(100, Long.MAX_VALUE));
|
||||
retryTemplate.setBackOffPolicy(new FixedBackOff(Duration.ofMillis(10)));
|
||||
|
||||
assertThatExceptionOfType(RetryException.class)
|
||||
.isThrownBy(() -> retryTemplate.execute(retryable))
|
||||
|
||||
Reference in New Issue
Block a user