Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -103,6 +103,7 @@ public class ExponentialBackOff implements BackOff {
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The initial interval in milliseconds.
|
||||
*/
|
||||
@@ -183,12 +184,12 @@ public class ExponentialBackOff implements BackOff {
|
||||
|
||||
@Override
|
||||
public long nextBackOff() {
|
||||
if (currentElapsedTime >= maxElapsedTime) {
|
||||
if (this.currentElapsedTime >= maxElapsedTime) {
|
||||
return STOP;
|
||||
}
|
||||
|
||||
long nextInterval = computeNextInterval();
|
||||
currentElapsedTime += nextInterval;
|
||||
this.currentElapsedTime += nextInterval;
|
||||
return nextInterval;
|
||||
}
|
||||
|
||||
@@ -205,7 +206,7 @@ public class ExponentialBackOff implements BackOff {
|
||||
else {
|
||||
this.currentInterval = multiplyInterval(maxInterval);
|
||||
}
|
||||
return currentInterval;
|
||||
return this.currentInterval;
|
||||
}
|
||||
|
||||
private long multiplyInterval(long maxInterval) {
|
||||
@@ -217,9 +218,8 @@ public class ExponentialBackOff implements BackOff {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String i = (this.currentInterval < 0 ? "n/a" : this.currentInterval + "ms");
|
||||
final StringBuilder sb = new StringBuilder("ExponentialBackOff{");
|
||||
sb.append("currentInterval=").append(i);
|
||||
StringBuilder sb = new StringBuilder("ExponentialBackOff{");
|
||||
sb.append("currentInterval=").append(this.currentInterval < 0 ? "n/a" : this.currentInterval + "ms");
|
||||
sb.append(", multiplier=").append(getMultiplier());
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,6 +57,7 @@ public class FixedBackOff implements BackOff {
|
||||
this.maxAttempts = maxAttempts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the interval between two attempts in milliseconds.
|
||||
*/
|
||||
@@ -110,14 +111,13 @@ public class FixedBackOff implements BackOff {
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("FixedBackOff{");
|
||||
sb.append("interval=").append(FixedBackOff.this.interval);
|
||||
String attemptValue = (FixedBackOff.this.maxAttempts == Long.MAX_VALUE ? "unlimited"
|
||||
: String.valueOf(FixedBackOff.this.maxAttempts));
|
||||
String attemptValue = (FixedBackOff.this.maxAttempts == Long.MAX_VALUE ?
|
||||
"unlimited" : String.valueOf(FixedBackOff.this.maxAttempts));
|
||||
sb.append(", currentAttempts=").append(this.currentAttempts);
|
||||
sb.append(", maxAttempts=").append(attemptValue);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user