Skip to content

Commit f51933d

Browse files
garyrussellartembilan
authored andcommitted
Fix possibleAuthenticationFailureFatal
This property can be set via a global property bean but the wrong boolean was being tested to enable the check. It should perform the check if the boolean has not already been explicitly set. **cherry-pick to 2.1.x** # Conflicts: # spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/AsyncListenerTests.java
1 parent fe425cb commit f51933d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ private void checkMissingQueuesFatalFromProperty() {
18481848
}
18491849

18501850
private void checkPossibleAuthenticationFailureFatalFromProperty() {
1851-
if (!isPossibleAuthenticationFailureFatal()) {
1851+
if (!isPossibleAuthenticationFailureFatalSet()) {
18521852
try {
18531853
ApplicationContext context = getApplicationContext();
18541854
if (context != null) {

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/AsyncListenerTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.HashMap;
2424
import java.util.List;
2525
import java.util.Map;
26+
import java.util.Properties;
2627
import java.util.concurrent.CountDownLatch;
2728
import java.util.concurrent.TimeUnit;
2829
import java.util.concurrent.atomic.AtomicBoolean;
@@ -44,8 +45,10 @@
4445
import org.springframework.amqp.rabbit.core.RabbitAdmin;
4546
import org.springframework.amqp.rabbit.core.RabbitTemplate;
4647
import org.springframework.amqp.rabbit.junit.BrokerRunning;
48+
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry;
4749
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
4850
import org.springframework.amqp.support.converter.MessageConverter;
51+
import org.springframework.amqp.utils.test.TestUtils;
4952
import org.springframework.beans.factory.annotation.Autowired;
5053
import org.springframework.context.annotation.Bean;
5154
import org.springframework.context.annotation.Configuration;
@@ -104,6 +107,9 @@ public class AsyncListenerTests {
104107
@Autowired
105108
private Listener listener;
106109

110+
@Autowired
111+
private RabbitListenerEndpointRegistry registry;
112+
107113
@Test
108114
public void testAsyncListener() throws Exception {
109115
assertThat(this.rabbitTemplate.convertSendAndReceive(this.queue1.getName(), "foo")).isEqualTo("FOO");
@@ -134,6 +140,12 @@ public void testOverrideDontRequeue() throws Exception {
134140
assertThat(this.rabbitTemplate.convertSendAndReceive(this.queue7.getName(), "foo")).isEqualTo("listen7");
135141
}
136142

143+
@Test
144+
public void testAuthByProps() {
145+
assertThat(TestUtils.getPropertyValue(this.registry.getListenerContainer("foo"),
146+
"possibleAuthenticationFailureFatal", Boolean.class)).isFalse();
147+
}
148+
137149
@Configuration
138150
@EnableRabbit
139151
public static class EnableRabbitConfig {
@@ -253,6 +265,13 @@ public Listener listener() {
253265
return new Listener();
254266
}
255267

268+
@Bean("spring.amqp.global.properties")
269+
public Properties properties() {
270+
Properties props = new Properties();
271+
props.setProperty("mlc.possible.authentication.failure.fatal", "false");
272+
return props;
273+
}
274+
256275
}
257276

258277
@Component

0 commit comments

Comments
 (0)