Skip to content

Commit 2b4b96b

Browse files
3pacccccclhotari
authored andcommitted
[fix][test] fix flaky GrowableArrayBlockingQueueTest.testPollBlockingThreadsTermination (apache#24576)
Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit e5cd79a) (cherry picked from commit e73c8f9)
1 parent 4eb0d98 commit 2b4b96b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleProducerConsumerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4176,8 +4176,8 @@ public void multiThreadConsumerReceiveThrowExceptionWhenConsumerClose() throws E
41764176
consumer.receive();
41774177
fail("thread should have been interrupted");
41784178
} catch (PulsarClientException e) {
4179-
terminateCompletedLatch.countDown();
41804179
interruptedThreadCount.incrementAndGet();
4180+
terminateCompletedLatch.countDown();
41814181
}
41824182
}).start();
41834183
}

pulsar-common/src/test/java/org/apache/pulsar/common/util/collections/GrowableArrayBlockingQueueTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ public void testTakeBlockingThreadsTermination() throws InterruptedException {
226226
fail("thread should have been interrupted");
227227
} catch (InterruptedException e) {
228228
// Expected interruption, record and notify
229-
terminateCompletedLatch.countDown();
230229
interruptedThreadCount.incrementAndGet();
230+
terminateCompletedLatch.countDown();
231231
}
232232
}).start();
233233
}
@@ -260,8 +260,8 @@ public void testPollBlockingThreadsTermination() throws InterruptedException {
260260
Integer poll = queue.poll(1, TimeUnit.HOURS);
261261
// should return a null value if queue is terminated
262262
assertNull(poll);
263-
terminateCompletedLatch.countDown();
264263
terminateThreadCount.incrementAndGet();
264+
terminateCompletedLatch.countDown();
265265
} catch (InterruptedException e) {
266266
throw new RuntimeException(e);
267267
}
@@ -295,15 +295,15 @@ public void testPollTakeMixBlockingThreadsTermination() throws InterruptedExcept
295295
try {
296296
queue.take();
297297
} catch (InterruptedException e) {
298-
terminateCompletedLatch.countDown();
299298
terminateThreadCount.incrementAndGet();
299+
terminateCompletedLatch.countDown();
300300
}
301301
} else {
302302
try {
303303
Integer poll = queue.poll(1, TimeUnit.HOURS);
304304
assertNull(poll);
305-
terminateCompletedLatch.countDown();
306305
terminateThreadCount.incrementAndGet();
306+
terminateCompletedLatch.countDown();
307307
} catch (InterruptedException e) {
308308
throw new RuntimeException(e);
309309
}

0 commit comments

Comments
 (0)