Skip to content

Commit 1a17848

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**
1 parent 30d257b commit 1a17848

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
@@ -1820,7 +1820,7 @@ private void checkMissingQueuesFatalFromProperty() {
18201820
}
18211821

18221822
private void checkPossibleAuthenticationFailureFatalFromProperty() {
1823-
if (!isPossibleAuthenticationFailureFatal()) {
1823+
if (!isPossibleAuthenticationFailureFatalSet()) {
18241824
try {
18251825
ApplicationContext context = getApplicationContext();
18261826
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;
@@ -42,8 +43,10 @@
4243
import org.springframework.amqp.rabbit.core.RabbitAdmin;
4344
import org.springframework.amqp.rabbit.core.RabbitTemplate;
4445
import org.springframework.amqp.rabbit.junit.RabbitAvailable;
46+
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry;
4547
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
4648
import org.springframework.amqp.support.converter.MessageConverter;
49+
import org.springframework.amqp.utils.test.TestUtils;
4750
import org.springframework.beans.factory.annotation.Autowired;
4851
import org.springframework.context.annotation.Bean;
4952
import org.springframework.context.annotation.Configuration;
@@ -98,6 +101,9 @@ public class AsyncListenerTests {
98101
@Autowired
99102
private Listener listener;
100103

104+
@Autowired
105+
private RabbitListenerEndpointRegistry registry;
106+
101107
@Test
102108
public void testAsyncListener() throws Exception {
103109
assertThat(this.rabbitTemplate.convertSendAndReceive(this.queue1.getName(), "foo")).isEqualTo("FOO");
@@ -128,6 +134,12 @@ public void testOverrideDontRequeue() throws Exception {
128134
assertThat(this.rabbitTemplate.convertSendAndReceive(this.queue7.getName(), "foo")).isEqualTo("listen7");
129135
}
130136

137+
@Test
138+
public void testAuthByProps() {
139+
assertThat(TestUtils.getPropertyValue(this.registry.getListenerContainer("foo"),
140+
"possibleAuthenticationFailureFatal", Boolean.class)).isFalse();
141+
}
142+
131143
@Configuration
132144
@EnableRabbit
133145
public static class EnableRabbitConfig {
@@ -247,6 +259,13 @@ public Listener listener() {
247259
return new Listener();
248260
}
249261

262+
@Bean("spring.amqp.global.properties")
263+
public Properties properties() {
264+
Properties props = new Properties();
265+
props.setProperty("mlc.possible.authentication.failure.fatal", "false");
266+
return props;
267+
}
268+
250269
}
251270

252271
@Component

0 commit comments

Comments
 (0)