Commit 46ea4a25 authored by Madhura Bhave's avatar Madhura Bhave

isPublisherConfirms in RabbitProperties should not throw NPE

Fixes gh-17967
parent fb846f43
......@@ -278,7 +278,7 @@ public class RabbitProperties {
@DeprecatedConfigurationProperty(reason = "replaced to support additional confirm types",
replacement = "spring.rabbitmq.publisher-confirm-type")
public boolean isPublisherConfirms() {
return this.publisherConfirmType.equals(ConfirmType.CORRELATED);
return ConfirmType.CORRELATED.equals(this.publisherConfirmType);
}
@Deprecated
......
......@@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
......@@ -240,4 +241,24 @@ class RabbitPropertiesTests {
assertThat(container).hasFieldOrPropertyWithValue("missingQueuesFatal", direct.isMissingQueuesFatal());
}
@Test
@Deprecated
void isPublisherConfirmsShouldDefaultToFalse() {
assertThat(this.properties.isPublisherConfirms()).isEqualTo(false);
}
@Test
@Deprecated
void isPublisherConfirmsWhenPublisherConfirmsTypeSimpleShouldBeFalse() {
this.properties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.SIMPLE);
assertThat(this.properties.isPublisherConfirms()).isEqualTo(false);
}
@Test
@Deprecated
void isPublisherConfirmsWhenPublisherConfirmsTypeCorrelatedShouldBeTrue() {
this.properties.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
assertThat(this.properties.isPublisherConfirms()).isEqualTo(true);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment