Skip to content

Commit

Permalink
TESTS: Fix Random Fail in MockTcpTransportTests (#33061) (#33307)
Browse files Browse the repository at this point in the history
* `foobar.txGet()` appears to return before `serviceB.stop()` returns, causing `ServiceB.close()` to run concurrently with the `stop` call and running into a race codition
* Closes #32863
  • Loading branch information
original-brownbear authored Aug 31, 2018
1 parent c168c03 commit 908c010
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ public void onAfter() {

public void testNotifyOnShutdown() throws Exception {
final CountDownLatch latch2 = new CountDownLatch(1);
final CountDownLatch latch3 = new CountDownLatch(1);
try {
serviceA.registerRequestHandler("internal:foobar", StringMessageRequest::new, ThreadPool.Names.GENERIC,
(request, channel) -> {
Expand All @@ -773,6 +774,8 @@ public void testNotifyOnShutdown() throws Exception {
serviceB.stop();
} catch (Exception e) {
fail(e.getMessage());
} finally {
latch3.countDown();
}
});
TransportFuture<TransportResponse.Empty> foobar = serviceB.submitRequest(nodeA, "internal:foobar",
Expand All @@ -784,6 +787,7 @@ public void testNotifyOnShutdown() throws Exception {
} catch (TransportException ex) {

}
latch3.await();
} finally {
serviceB.close(); // make sure we are fully closed here otherwise we might run into assertions down the road
serviceA.disconnectFromNode(nodeB);
Expand Down

0 comments on commit 908c010

Please sign in to comment.