isPublisherConfirms in RabbitProperties should not throw NPE

Fixes gh-17967
pull/17968/head
Madhura Bhave 5 years ago
parent fb846f434f
commit 46ea4a2501

@ -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);
}
}

Loading…
Cancel
Save