Skip to content

Commit 490bdd1

Browse files
Maysbrannen
May
authored andcommitted
Use Math.min() in ExponentialBackOff
Use Math.min() instead of doing it manually in ExponentialBackOff. Closes gh-25381
1 parent abe16ee commit 490bdd1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

spring-core/src/main/java/org/springframework/util/backoff/ExponentialBackOff.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -200,8 +200,7 @@ private long computeNextInterval() {
200200
}
201201
else if (this.currentInterval < 0) {
202202
long initialInterval = getInitialInterval();
203-
this.currentInterval = (initialInterval < maxInterval
204-
? initialInterval : maxInterval);
203+
this.currentInterval = Math.min(initialInterval, maxInterval);
205204
}
206205
else {
207206
this.currentInterval = multiplyInterval(maxInterval);
@@ -212,7 +211,7 @@ else if (this.currentInterval < 0) {
212211
private long multiplyInterval(long maxInterval) {
213212
long i = this.currentInterval;
214213
i *= getMultiplier();
215-
return (i > maxInterval ? maxInterval : i);
214+
return Math.min(i, maxInterval);
216215
}
217216

218217

0 commit comments

Comments
 (0)