HADOOP-14669. GenericTestUtils.waitFor should use monotonic time. Contributed by Daniel Templeton

(cherry picked from commit df180259b0)
This commit is contained in:
Jason Lowe 2017-07-19 09:41:22 -05:00
parent f806e8627b
commit 057631c031
1 changed files with 2 additions and 2 deletions

View File

@ -356,10 +356,10 @@ public abstract class GenericTestUtils {
Preconditions.checkArgument(waitForMillis >= checkEveryMillis, Preconditions.checkArgument(waitForMillis >= checkEveryMillis,
ERROR_INVALID_ARGUMENT); ERROR_INVALID_ARGUMENT);
long st = Time.now(); long st = Time.monotonicNow();
boolean result = check.get(); boolean result = check.get();
while (!result && (Time.now() - st < waitForMillis)) { while (!result && (Time.monotonicNow() - st < waitForMillis)) {
Thread.sleep(checkEveryMillis); Thread.sleep(checkEveryMillis);
result = check.get(); result = check.get();
} }