You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/03/25 12:17:43 UTC
[GitHub] [flink] StephanEwen commented on a change in pull request #15344: [FLINK-21564][tests] Don't call condition or throw exception after condition met for CommonTestUtils.waitUntil
StephanEwen commented on a change in pull request #15344:
URL: https://github.com/apache/flink/pull/15344#discussion_r601431370
##########
File path: flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java
##########
@@ -198,16 +205,17 @@ public static void assertThrows(
@SuppressWarnings("BusyWait")
public static void waitUtil(Supplier<Boolean> condition, Duration timeout, String errorMsg)
throws TimeoutException, InterruptedException {
- long timeoutMs = timeout.toMillis();
- if (timeoutMs <= 0) {
+ long timeoutNanos = timeout.toNanos();
+ if (timeoutNanos <= 0) {
throw new IllegalArgumentException("The timeout must be positive.");
}
- long startingTime = System.currentTimeMillis();
- while (!condition.get() && System.currentTimeMillis() - startingTime < timeoutMs) {
+ long startingTime = System.nanoTime();
Review comment:
Can we change this to use `Deadline` as well, to set a good example to not manually use the time functions (which is safer, many contributors get the time functions wrong accidentally).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org