Skip to content

Commit 6f91344

Browse files
3pacccccclhotari
andcommitted
[fix][test] fix flaky GrowableArrayBlockingQueueTest.testPollBlockingThreadsTermination (#24576)
Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit e5cd79a)
1 parent eca0fae commit 6f91344

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
@@ -4091,8 +4091,8 @@ public void multiThreadConsumerReceiveThrowExceptionWhenConsumerClose() throws E
40914091
consumer.receive();
40924092
fail("thread should have been interrupted");
40934093
} catch (PulsarClientException e) {
4094-
terminateCompletedLatch.countDown();
40954094
interruptedThreadCount.incrementAndGet();
4095+
terminateCompletedLatch.countDown();
40964096
}
40974097
}).start();
40984098
}

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
@@ -229,8 +229,8 @@ public void testTakeBlockingThreadsTermination() throws InterruptedException {
229229
fail("thread should have been interrupted");
230230
} catch (InterruptedException e) {
231231
// Expected interruption, record and notify
232-
terminateCompletedLatch.countDown();
233232
interruptedThreadCount.incrementAndGet();
233+
terminateCompletedLatch.countDown();
234234
}
235235
}).start();
236236
}
@@ -263,8 +263,8 @@ public void testPollBlockingThreadsTermination() throws InterruptedException {
263263
Integer poll = queue.poll(1, TimeUnit.HOURS);
264264
// should return a null value if queue is terminated
265265
assertNull(poll);
266-
terminateCompletedLatch.countDown();
267266
terminateThreadCount.incrementAndGet();
267+
terminateCompletedLatch.countDown();
268268
} catch (InterruptedException e) {
269269
throw new RuntimeException(e);
270270
}
@@ -298,15 +298,15 @@ public void testPollTakeMixBlockingThreadsTermination() throws InterruptedExcept
298298
try {
299299
queue.take();
300300
} catch (InterruptedException e) {
301-
terminateCompletedLatch.countDown();
302301
terminateThreadCount.incrementAndGet();
302+
terminateCompletedLatch.countDown();
303303
}
304304
} else {
305305
try {
306306
Integer poll = queue.poll(1, TimeUnit.HOURS);
307307
assertNull(poll);
308-
terminateCompletedLatch.countDown();
309308
terminateThreadCount.incrementAndGet();
309+
terminateCompletedLatch.countDown();
310310
} catch (InterruptedException e) {
311311
throw new RuntimeException(e);
312312
}

0 commit comments

Comments
 (0)