Skip to content

Commit 908c010

Browse files
TESTS: Fix Random Fail in MockTcpTransportTests (#33061) (#33307)
* `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
1 parent c168c03 commit 908c010

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ public void onAfter() {
764764

765765
public void testNotifyOnShutdown() throws Exception {
766766
final CountDownLatch latch2 = new CountDownLatch(1);
767+
final CountDownLatch latch3 = new CountDownLatch(1);
767768
try {
768769
serviceA.registerRequestHandler("internal:foobar", StringMessageRequest::new, ThreadPool.Names.GENERIC,
769770
(request, channel) -> {
@@ -773,6 +774,8 @@ public void testNotifyOnShutdown() throws Exception {
773774
serviceB.stop();
774775
} catch (Exception e) {
775776
fail(e.getMessage());
777+
} finally {
778+
latch3.countDown();
776779
}
777780
});
778781
TransportFuture<TransportResponse.Empty> foobar = serviceB.submitRequest(nodeA, "internal:foobar",
@@ -784,6 +787,7 @@ public void testNotifyOnShutdown() throws Exception {
784787
} catch (TransportException ex) {
785788

786789
}
790+
latch3.await();
787791
} finally {
788792
serviceB.close(); // make sure we are fully closed here otherwise we might run into assertions down the road
789793
serviceA.disconnectFromNode(nodeB);

0 commit comments

Comments
 (0)