1010: Fixed all of the blocking and critical Sonarcloud errors (#1020)
* 1011: Added SuppressWarnings for SonarCloud errors All of these files are causing SonarCloud to report the following error: Loops should not be infinite Since these instances all require an infinite loop that will never end, these warnings should be disabled so that SonarCloud no longer reports them as error. The rule is: squid:S2189 * 1011: Made all of the randoms static and final According to SonarCloud rule: "Random" objects should be reused, randoms should not be recreated. This commit has taken all of the Randoms and made them constant variables in the files that are using them.
This commit is contained in:
committed by
Ilkka Seppälä
parent
8a4844792f
commit
7c5d5f6b0d
@ -37,6 +37,7 @@ import java.util.function.Predicate;
|
||||
* @param <T> the remote op's return type
|
||||
*/
|
||||
public final class RetryExponentialBackoff<T> implements BusinessOperation<T> {
|
||||
private static final Random RANDOM = new Random();
|
||||
private final BusinessOperation<T> op;
|
||||
private final int maxAttempts;
|
||||
private final long maxDelay;
|
||||
@ -98,8 +99,7 @@ public final class RetryExponentialBackoff<T> implements BusinessOperation<T> {
|
||||
}
|
||||
|
||||
try {
|
||||
Random rand = new Random();
|
||||
long testDelay = (long) Math.pow(2, this.attempts()) * 1000 + rand.nextInt(1000);
|
||||
long testDelay = (long) Math.pow(2, this.attempts()) * 1000 + RANDOM.nextInt(1000);
|
||||
long delay = testDelay < this.maxDelay ? testDelay : maxDelay;
|
||||
Thread.sleep(delay);
|
||||
} catch (InterruptedException f) {
|
||||
|
Reference in New Issue
Block a user