[FLINK-6509] [tests] Perform TestingListener#waitForNewLeader under lock Performin TestingListener#waitForNewLeader under the lock which is also hold when updating the leader information makes sure that leader changes won't go unnoticed. This led before to failing test cases due to timeouts.
This closes #3853. Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/d88a62f9 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/d88a62f9 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/d88a62f9 Branch: refs/heads/release-1.3 Commit: d88a62f9c0030a35ffdec5c252c8428ab8960521 Parents: 9708550 Author: Till Rohrmann <[email protected]> Authored: Tue May 9 13:13:02 2017 +0200 Committer: Stefan Richter <[email protected]> Committed: Sun May 14 14:07:26 2017 +0200 ---------------------------------------------------------------------- .../apache/flink/runtime/leaderelection/TestingListener.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/d88a62f9/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingListener.java ---------------------------------------------------------------------- diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingListener.java b/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingListener.java index 87decc7..8571505 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingListener.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingListener.java @@ -51,11 +51,11 @@ public class TestingListener implements LeaderRetrievalListener { long start = System.currentTimeMillis(); long curTimeout; - while ( + synchronized (lock) { + while ( exception == null && - (address == null || address.equals(oldAddress)) && - (curTimeout = timeout - System.currentTimeMillis() + start) > 0) { - synchronized (lock) { + (address == null || address.equals(oldAddress)) && + (curTimeout = timeout - System.currentTimeMillis() + start) > 0) { try { lock.wait(curTimeout); } catch (InterruptedException e) {
