Skip to content

Commit

Permalink
Ensure listener is done in testPendingConnectListeners
Browse files Browse the repository at this point in the history
We need to ensure that we do not fail on InterruptedException in the
connection listener as this can happen when the connection is closed.

Closes #59879
  • Loading branch information
dnhatn committed Jul 28, 2020
1 parent 50fea0d commit 673dd65
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,6 @@ public void onFailure(Exception e) {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/59879")
public void testPendingConnectListeners() throws IOException, InterruptedException {
List<DiscoveryNode> knownNodes = new CopyOnWriteArrayList<>();
try (MockTransportService seedTransport = startTransport("seed_node", knownNodes, Version.CURRENT);
Expand All @@ -1225,6 +1224,7 @@ public void testPendingConnectListeners() throws IOException, InterruptedExcepti
ConnectionManager connectionManager = connection.getConnectionManager();
CountDownLatch connectionOpenedLatch = new CountDownLatch(1);
CountDownLatch connectionBlockedLatch = new CountDownLatch(1);
CountDownLatch completionLatch = new CountDownLatch(1);
connectionManager.addListener(new TransportConnectionListener() {
@Override
public void onConnectionOpened(Transport.Connection connection) {
Expand All @@ -1233,6 +1233,8 @@ public void onConnectionOpened(Transport.Connection connection) {
connectionBlockedLatch.await();
} catch (InterruptedException e) {
throw new AssertionError(e);
} finally {
completionLatch.countDown();
}
}
});
Expand Down Expand Up @@ -1261,6 +1263,7 @@ public void onFailure(Exception e) {
}
} finally {
connectionBlockedLatch.countDown();
completionLatch.await();
thread.join();
}
}
Expand Down

0 comments on commit 673dd65

Please sign in to comment.