Skip to content

Commit 61c7ae5

Browse files
committed
Fix intermittent failure in BroadcasterExecutorTest
Signed-off-by: jansupol <[email protected]>
1 parent 876c83d commit 61c7ae5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterExecutorTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -152,13 +152,15 @@ private static class CustomClientAsyncExecutor extends ThreadPoolExecutorProvide
152152
@Test
153153
public void test() throws InterruptedException {
154154
final String[] onEventThreadName = {""};
155+
final CountDownLatch onEventLatch = new CountDownLatch(1);
155156
SseEventSource eventSource = SseEventSource
156157
.target(target().path("sse/events"))
157158
.build();
158159

159160
eventSource.register((event) -> {
160161
LOGGER.info("Event: " + event + " from: " + Thread.currentThread().getName());
161162
onEventThreadName[0] = Thread.currentThread().getName();
163+
onEventLatch.countDown();
162164
}
163165
);
164166

@@ -174,6 +176,7 @@ public void test() throws InterruptedException {
174176
Assertions.assertTrue(sendThreadOk, "send either not invoked at all or from wrong thread");
175177
Assertions.assertTrue(onCompleteThreadOk, "onComplete either not invoked at all or from wrong thread");
176178

179+
Assertions.assertTrue(onEventLatch.await(2_000L, TimeUnit.MILLISECONDS));
177180
Assertions.assertTrue(onEventThreadName[0].startsWith("custom-client-executor"),
178181
"Client event called from wrong thread ( " + onEventThreadName[0] + ")");
179182
}

0 commit comments

Comments
 (0)