You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ga...@apache.org on 2019/08/04 18:52:14 UTC
[flink] 04/04: [FLINK-13508][tests] Prevent waitUntilCondition()
from sleeping negative time
This is an automated email from the ASF dual-hosted git repository.
gary pushed a commit to branch release-1.9
in repository https://gitbox.apache.org/repos/asf/flink.git
commit d609917d706e6928d6eee1535c9d12b90b6ae6f8
Author: Gary Yao <ga...@apache.org>
AuthorDate: Wed Jul 31 13:41:42 2019 +0200
[FLINK-13508][tests] Prevent waitUntilCondition() from sleeping negative time
This fixes that CommonTestUtils#waitUntilCondition() may invoke Thread.sleep()
with a negative argument.
---
.../test/java/org/apache/flink/runtime/testutils/CommonTestUtils.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/CommonTestUtils.java b/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/CommonTestUtils.java
index b45ebd7..a58cbfd 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/CommonTestUtils.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/testutils/CommonTestUtils.java
@@ -117,7 +117,8 @@ public class CommonTestUtils {
public static void waitUntilCondition(SupplierWithException<Boolean, Exception> condition, Deadline timeout, long retryIntervalMillis) throws Exception {
while (timeout.hasTimeLeft() && !condition.get()) {
- Thread.sleep(Math.min(retryIntervalMillis, timeout.timeLeft().toMillis()));
+ final long timeLeft = Math.max(0, timeout.timeLeft().toMillis());
+ Thread.sleep(Math.min(retryIntervalMillis, timeLeft));
}
if (!timeout.hasTimeLeft()) {