Skip to content

Commit 9c25d17

Browse files
committed
Fix race in test
- the second confirmation could arrive before the latch was counted down, resulting in an NPE and failed test.
1 parent 9c1bdcd commit 9c25d17

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplatePublisherCallbacksIntegrationTests3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public void testRepublishOnNackThreadNoExchange() throws Exception {
6060
final RabbitTemplate template = new RabbitTemplate(cf);
6161
final CountDownLatch confirmLatch = new CountDownLatch(2);
6262
template.setConfirmCallback((cd, a, c) -> {
63-
if (confirmLatch.getCount() == 2) {
63+
confirmLatch.countDown();
64+
if (confirmLatch.getCount() == 1) {
6465
template.convertAndSend(QUEUE1, ((MyCD) cd).payload);
6566
}
66-
confirmLatch.countDown();
6767
});
6868
template.convertAndSend("bad.exchange", "junk", "foo", new MyCD("foo"));
6969
assertThat(confirmLatch.await(10, TimeUnit.SECONDS)).isTrue();

0 commit comments

Comments
 (0)