Skip to content

Commit 063e990

Browse files
committed
Rename maxAttempts to maxRetries
Closes gh-48023
1 parent bdf3eb5 commit 063e990

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

core/spring-boot/src/main/java/org/springframework/boot/retry/RetryPolicySettings.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public final class RetryPolicySettings {
3939
/**
4040
* Default number of retry attempts.
4141
*/
42-
public static final long DEFAULT_MAX_ATTEMPTS = RetryPolicy.Builder.DEFAULT_MAX_ATTEMPTS;
42+
public static final long DEFAULT_MAX_RETRIES = RetryPolicy.Builder.DEFAULT_MAX_RETRIES;
4343

4444
/**
4545
* Default initial delay.
@@ -62,7 +62,7 @@ public final class RetryPolicySettings {
6262

6363
private @Nullable Predicate<Throwable> exceptionPredicate;
6464

65-
private Long maxAttempts = DEFAULT_MAX_ATTEMPTS;
65+
private Long maxRetries = DEFAULT_MAX_RETRIES;
6666

6767
private Duration delay = DEFAULT_DELAY;
6868

@@ -84,7 +84,7 @@ public RetryPolicy createRetryPolicy() {
8484
map.from(this::getExceptionIncludes).to(builder::includes);
8585
map.from(this::getExceptionExcludes).to(builder::excludes);
8686
map.from(this::getExceptionPredicate).to(builder::predicate);
87-
map.from(this::getMaxAttempts).to(builder::maxAttempts);
87+
map.from(this::getMaxRetries).to(builder::maxRetries);
8888
map.from(this::getDelay).to(builder::delay);
8989
map.from(this::getJitter).to(builder::jitter);
9090
map.from(this::getMultiplier).to(builder::multiplier);
@@ -153,18 +153,19 @@ public void setExceptionPredicate(@Nullable Predicate<Throwable> exceptionPredic
153153
/**
154154
* Return the maximum number of retry attempts.
155155
* @return the maximum number of retry attempts
156-
* @see #DEFAULT_MAX_ATTEMPTS
156+
* @see #DEFAULT_MAX_RETRIES
157157
*/
158-
public Long getMaxAttempts() {
159-
return this.maxAttempts;
158+
public Long getMaxRetries() {
159+
return this.maxRetries;
160160
}
161161

162162
/**
163163
* Specify the maximum number of retry attempts.
164-
* @param maxAttempts the max attempts (must be equal or greater than zero)
164+
* @param maxRetries the maximum number of retry attempts (must be equal or greater
165+
* than zero)
165166
*/
166-
public void setMaxAttempts(Long maxAttempts) {
167-
this.maxAttempts = maxAttempts;
167+
public void setMaxRetries(Long maxRetries) {
168+
this.maxRetries = maxRetries;
168169
}
169170

170171
/**

core/spring-boot/src/test/java/org/springframework/boot/retry/RetryPolicySettingsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void createRetryPolicyWithDefaultsMatchesBackOffDefaults() {
128128
@Test
129129
void createRetryPolicyWithCustomAttributes() {
130130
RetryPolicySettings settings = new RetryPolicySettings();
131-
settings.setMaxAttempts(10L);
131+
settings.setMaxRetries(10L);
132132
settings.setDelay(Duration.ofSeconds(2));
133133
settings.setJitter(Duration.ofMillis(500));
134134
settings.setMultiplier(2.0);

module/spring-boot-amqp/src/main/java/org/springframework/boot/amqp/autoconfigure/RabbitProperties.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,9 +1102,9 @@ public static class Retry {
11021102
private boolean enabled;
11031103

11041104
/**
1105-
* Maximum number of attempts to deliver a message.
1105+
* Maximum number of retry attempts to deliver a message.
11061106
*/
1107-
private long maxAttempts = 3;
1107+
private long maxRetries = 3;
11081108

11091109
/**
11101110
* Duration between the first and second attempt to deliver a message.
@@ -1129,12 +1129,12 @@ public void setEnabled(boolean enabled) {
11291129
this.enabled = enabled;
11301130
}
11311131

1132-
public long getMaxAttempts() {
1133-
return this.maxAttempts;
1132+
public long getMaxRetries() {
1133+
return this.maxRetries;
11341134
}
11351135

1136-
public void setMaxAttempts(long maxAttempts) {
1137-
this.maxAttempts = maxAttempts;
1136+
public void setMaxRetries(long maxRetries) {
1137+
this.maxRetries = maxRetries;
11381138
}
11391139

11401140
public Duration getInitialInterval() {
@@ -1164,7 +1164,7 @@ public void setMaxInterval(Duration maxInterval) {
11641164
RetryPolicySettings initializeRetryPolicySettings() {
11651165
PropertyMapper map = PropertyMapper.get();
11661166
RetryPolicySettings settings = new RetryPolicySettings();
1167-
map.from(this::getMaxAttempts).to(settings::setMaxAttempts);
1167+
map.from(this::getMaxRetries).to(settings::setMaxRetries);
11681168
map.from(this::getInitialInterval).to(settings::setDelay);
11691169
map.from(this::getMultiplier).to(settings::setMultiplier);
11701170
map.from(this::getMaxInterval).to(settings::setMaxDelay);

module/spring-boot-amqp/src/test/java/org/springframework/boot/amqp/autoconfigure/RabbitAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ ConnectionNameStrategy myConnectionNameStrategy() {
12241224
@Configuration(proxyBeanMethods = false)
12251225
static class RabbitRetryTemplateCustomizerConfiguration {
12261226

1227-
private final RetryPolicy retryPolicy = RetryPolicy.withMaxAttempts(1);
1227+
private final RetryPolicy retryPolicy = RetryPolicy.withMaxRetries(1);
12281228

12291229
@Bean
12301230
RabbitTemplateRetrySettingsCustomizer rabbitTemplateRetryTemplateCustomizer() {

module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/KafkaAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private void applyKafkaConnectionDetailsForAdmin(Map<String, Object> properties,
228228

229229
static BackOff getBackOff(Backoff retryTopicBackoff) {
230230
PropertyMapper map = PropertyMapper.get();
231-
RetryPolicy.Builder builder = RetryPolicy.builder().maxAttempts(Long.MAX_VALUE);
231+
RetryPolicy.Builder builder = RetryPolicy.builder().maxRetries(Long.MAX_VALUE);
232232
map.from(retryTopicBackoff.getDelay()).to(builder::delay);
233233
map.from(retryTopicBackoff.getMaxDelay()).when(Predicate.not(Duration::isZero)).to(builder::maxDelay);
234234
map.from(retryTopicBackoff.getMultiplier()).to(builder::multiplier);

0 commit comments

Comments
 (0)