Skip to content

Commit a9dc221

Browse files
garyrussellartembilan
authored andcommitted
Fix race in test
- the second confirmation could arrive before the latch was counted down, resulting in an NPE and failed test.
1 parent 0f862c7 commit a9dc221

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
@@ -58,10 +58,10 @@ public void testRepublishOnNackThreadNoExchange() throws Exception {
5858
final RabbitTemplate template = new RabbitTemplate(cf);
5959
final CountDownLatch confirmLatch = new CountDownLatch(2);
6060
template.setConfirmCallback((cd, a, c) -> {
61-
if (confirmLatch.getCount() == 2) {
61+
confirmLatch.countDown();
62+
if (confirmLatch.getCount() == 1) {
6263
template.convertAndSend(QUEUE1, ((MyCD) cd).payload);
6364
}
64-
confirmLatch.countDown();
6565
});
6666
template.convertAndSend("bad.exchange", "junk", "foo", new MyCD("foo"));
6767
assertThat(confirmLatch.await(10, TimeUnit.SECONDS)).isTrue();

0 commit comments

Comments
 (0)