From df180259b0cc3660e199e85447c7193bee51751c Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Wed, 19 Jul 2017 09:41:22 -0500 Subject: [PATCH] HADOOP-14669. GenericTestUtils.waitFor should use monotonic time. Contributed by Daniel Templeton --- .../test/java/org/apache/hadoop/test/GenericTestUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java index 38a0c6c776..9291bb039d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java @@ -356,10 +356,10 @@ public static void waitFor(Supplier check, int checkEveryMillis, Preconditions.checkArgument(waitForMillis >= checkEveryMillis, ERROR_INVALID_ARGUMENT); - long st = Time.now(); + long st = Time.monotonicNow(); boolean result = check.get(); - while (!result && (Time.now() - st < waitForMillis)) { + while (!result && (Time.monotonicNow() - st < waitForMillis)) { Thread.sleep(checkEveryMillis); result = check.get(); }