From 24da017883001ce267e0f185195b796a741e8c34 Mon Sep 17 00:00:00 2001 From: Brian Stansberry Date: Fri, 27 Sep 2024 11:50:21 -0500 Subject: [PATCH] [Issue_394] If ReactiveStreamsPublisherTckTest.createPublisher is called multiple times in a @Test method, await the cleanupLatch from previous calls before launching a new server. --- .../tck/sse/ReactiveStreamsPublisherTckTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/ReactiveStreamsPublisherTckTest.java b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/ReactiveStreamsPublisherTckTest.java index 00582565..a1dc11b6 100644 --- a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/ReactiveStreamsPublisherTckTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/ReactiveStreamsPublisherTckTest.java @@ -102,6 +102,16 @@ public Publisher createPublisher(long elements) { CountDownLatch stopLatch = new CountDownLatch(1); try { + if (cleanupLatch != null) { + // We null out cleanupLatch in a @BeforeTest method, so if it is not null + // we must be in a test that calls this multiple times in a single @Test method, + // e.g. a stochastic test. In this case we can't rely on having awaited cleanupLatch + // in our @AfterTest method, and we need to do it ourselves. + if (!cleanupLatch.await(30, TimeUnit.SECONDS)) { + // Just log; maybe by the time we create a new server the old one will be stopped. + LOG.error("Server did not close long after test completed"); + } + } cleanupLatch = new CountDownLatch(1); AtomicReference serverException = launchServer(stopLatch, es -> { for (long i = 0; i < elements; i++) {