Add nullability annotations to module/spring-boot-amqp
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:24], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:24], map[id:windows-latest name:Windows]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:17], map[id:windows-latest name:Windows]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:windows-latest name:Windows]) (push) Waiting to run Details
Run CodeQL Analysis / run-analysis (push) Waiting to run Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:17]) (push) Waiting to run Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run Details

See gh-46587
This commit is contained in:
Moritz Halbritter 2025-07-25 14:55:30 +02:00
parent 1fb95fbd18
commit f5dcf513b1
23 changed files with 205 additions and 154 deletions

View File

@ -17,6 +17,7 @@
package org.springframework.boot.docs.messaging.amqp.receiving.custom
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory
import org.springframework.amqp.rabbit.connection.ConnectionFactory
import org.springframework.boot.amqp.autoconfigure.SimpleRabbitListenerContainerFactoryConfigurer
import org.springframework.context.annotation.Bean
@ -34,8 +35,8 @@ class MyRabbitConfiguration {
return factory
}
fun getCustomConnectionFactory() : ConnectionFactory? {
return /**/ null
fun getCustomConnectionFactory() : ConnectionFactory {
return /**/ CachingConnectionFactory()
}
}

View File

@ -18,6 +18,8 @@ package org.springframework.boot.amqp.autoconfigure;
import java.util.stream.Collectors;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionNameStrategy;
import org.springframework.boot.context.properties.PropertyMapper;
@ -37,7 +39,7 @@ public abstract class AbstractConnectionFactoryConfigurer<T extends AbstractConn
private final RabbitProperties rabbitProperties;
private ConnectionNameStrategy connectionNameStrategy;
private @Nullable ConnectionNameStrategy connectionNameStrategy;
private final RabbitConnectionDetails connectionDetails;
@ -65,11 +67,11 @@ public abstract class AbstractConnectionFactoryConfigurer<T extends AbstractConn
this.connectionDetails = connectionDetails;
}
protected final ConnectionNameStrategy getConnectionNameStrategy() {
protected final @Nullable ConnectionNameStrategy getConnectionNameStrategy() {
return this.connectionNameStrategy;
}
public final void setConnectionNameStrategy(ConnectionNameStrategy connectionNameStrategy) {
public final void setConnectionNameStrategy(@Nullable ConnectionNameStrategy connectionNameStrategy) {
this.connectionNameStrategy = connectionNameStrategy;
}

View File

@ -19,6 +19,8 @@ package org.springframework.boot.amqp.autoconfigure;
import java.util.List;
import java.util.concurrent.Executor;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.rabbit.config.AbstractRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.config.RetryInterceptorBuilder;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
@ -40,15 +42,15 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractRabbitListenerContainerFactoryConfigurer<T extends AbstractRabbitListenerContainerFactory<?>> {
private MessageConverter messageConverter;
private @Nullable MessageConverter messageConverter;
private MessageRecoverer messageRecoverer;
private @Nullable MessageRecoverer messageRecoverer;
private List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
private @Nullable List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
private final RabbitProperties rabbitProperties;
private Executor taskExecutor;
private @Nullable Executor taskExecutor;
/**
* Creates a new configurer that will use the given {@code rabbitProperties}.
@ -63,7 +65,7 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer<T extends
* converter should be used.
* @param messageConverter the {@link MessageConverter}
*/
protected void setMessageConverter(MessageConverter messageConverter) {
protected void setMessageConverter(@Nullable MessageConverter messageConverter) {
this.messageConverter = messageConverter;
}
@ -71,7 +73,7 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer<T extends
* Set the {@link MessageRecoverer} to use or {@code null} to rely on the default.
* @param messageRecoverer the {@link MessageRecoverer}
*/
protected void setMessageRecoverer(MessageRecoverer messageRecoverer) {
protected void setMessageRecoverer(@Nullable MessageRecoverer messageRecoverer) {
this.messageRecoverer = messageRecoverer;
}
@ -79,7 +81,7 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer<T extends
* Set the {@link RabbitRetryTemplateCustomizer} instances to use.
* @param retryTemplateCustomizers the retry template customizers
*/
protected void setRetryTemplateCustomizers(List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) {
protected void setRetryTemplateCustomizers(@Nullable List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) {
this.retryTemplateCustomizers = retryTemplateCustomizers;
}
@ -87,7 +89,7 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer<T extends
* Set the task executor to use.
* @param taskExecutor the task executor
*/
public void setTaskExecutor(Executor taskExecutor) {
public void setTaskExecutor(@Nullable Executor taskExecutor) {
this.taskExecutor = taskExecutor;
}

View File

@ -19,6 +19,8 @@ package org.springframework.boot.amqp.autoconfigure;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.amqp.autoconfigure.RabbitProperties.Ssl;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundles;
@ -36,9 +38,9 @@ class PropertiesRabbitConnectionDetails implements RabbitConnectionDetails {
private final RabbitProperties properties;
private final SslBundles sslBundles;
private final @Nullable SslBundles sslBundles;
PropertiesRabbitConnectionDetails(RabbitProperties properties, SslBundles sslBundles) {
PropertiesRabbitConnectionDetails(RabbitProperties properties, @Nullable SslBundles sslBundles) {
this.properties = properties;
this.sslBundles = sslBundles;
}
@ -49,12 +51,12 @@ class PropertiesRabbitConnectionDetails implements RabbitConnectionDetails {
}
@Override
public String getPassword() {
public @Nullable String getPassword() {
return this.properties.determinePassword();
}
@Override
public String getVirtualHost() {
public @Nullable String getVirtualHost() {
return this.properties.determineVirtualHost();
}
@ -71,7 +73,7 @@ class PropertiesRabbitConnectionDetails implements RabbitConnectionDetails {
}
@Override
public SslBundle getSslBundle() {
public @Nullable SslBundle getSslBundle() {
Ssl ssl = this.properties.getSsl();
if (!ssl.determineEnabled()) {
return null;

View File

@ -18,6 +18,8 @@ package org.springframework.boot.amqp.autoconfigure;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.util.Assert;
@ -36,7 +38,7 @@ public interface RabbitConnectionDetails extends ConnectionDetails {
* Login user to authenticate to the broker.
* @return the login user to authenticate to the broker or {@code null}
*/
default String getUsername() {
default @Nullable String getUsername() {
return null;
}
@ -44,7 +46,7 @@ public interface RabbitConnectionDetails extends ConnectionDetails {
* Login to authenticate against the broker.
* @return the login to authenticate against the broker or {@code null}
*/
default String getPassword() {
default @Nullable String getPassword() {
return null;
}
@ -52,7 +54,7 @@ public interface RabbitConnectionDetails extends ConnectionDetails {
* Virtual host to use when connecting to the broker.
* @return the virtual host to use when connecting to the broker or {@code null}
*/
default String getVirtualHost() {
default @Nullable String getVirtualHost() {
return null;
}
@ -78,7 +80,7 @@ public interface RabbitConnectionDetails extends ConnectionDetails {
* SSL bundle to use.
* @return the SSL bundle to use
*/
default SslBundle getSslBundle() {
default @Nullable SslBundle getSslBundle() {
return null;
}

View File

@ -20,6 +20,7 @@ import java.time.Duration;
import com.rabbitmq.client.impl.CredentialsProvider;
import com.rabbitmq.client.impl.CredentialsRefreshService;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean;
import org.springframework.boot.amqp.autoconfigure.RabbitConnectionDetails.Address;
@ -53,9 +54,9 @@ public class RabbitConnectionFactoryBeanConfigurer {
private final RabbitConnectionDetails connectionDetails;
private CredentialsProvider credentialsProvider;
private @Nullable CredentialsProvider credentialsProvider;
private CredentialsRefreshService credentialsRefreshService;
private @Nullable CredentialsRefreshService credentialsRefreshService;
/**
* Creates a new configurer that will use the given {@code resourceLoader} and
@ -90,7 +91,7 @@ public class RabbitConnectionFactoryBeanConfigurer {
* @param sslBundles the SSL bundles
*/
public RabbitConnectionFactoryBeanConfigurer(ResourceLoader resourceLoader, RabbitProperties properties,
RabbitConnectionDetails connectionDetails, SslBundles sslBundles) {
RabbitConnectionDetails connectionDetails, @Nullable SslBundles sslBundles) {
Assert.notNull(resourceLoader, "'resourceLoader' must not be null");
Assert.notNull(properties, "'properties' must not be null");
Assert.notNull(connectionDetails, "'connectionDetails' must not be null");
@ -99,11 +100,11 @@ public class RabbitConnectionFactoryBeanConfigurer {
this.connectionDetails = connectionDetails;
}
public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
public void setCredentialsProvider(@Nullable CredentialsProvider credentialsProvider) {
this.credentialsProvider = credentialsProvider;
}
public void setCredentialsRefreshService(CredentialsRefreshService credentialsRefreshService) {
public void setCredentialsRefreshService(@Nullable CredentialsRefreshService credentialsRefreshService) {
this.credentialsRefreshService = credentialsRefreshService;
}

View File

@ -21,6 +21,8 @@ import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.AddressShuffleMode;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode;
@ -68,7 +70,7 @@ public class RabbitProperties {
* RabbitMQ port. Ignored if an address is set. Default to 5672, or 5671 if SSL is
* enabled.
*/
private Integer port;
private @Nullable Integer port;
/**
* Login user to authenticate to the broker.
@ -88,13 +90,13 @@ public class RabbitProperties {
/**
* Virtual host to use when connecting to the broker.
*/
private String virtualHost;
private @Nullable String virtualHost;
/**
* List of addresses to which the client should connect. When set, the host and port
* are ignored.
*/
private List<String> addresses;
private @Nullable List<String> addresses;
/**
* Mode used to shuffle configured addresses.
@ -106,7 +108,7 @@ public class RabbitProperties {
* seconds will be used.
*/
@DurationUnit(ChronoUnit.SECONDS)
private Duration requestedHeartbeat;
private @Nullable Duration requestedHeartbeat;
/**
* Number of channels per connection requested by the client. Use 0 for unlimited.
@ -121,12 +123,12 @@ public class RabbitProperties {
/**
* Type of publisher confirms to use.
*/
private ConfirmType publisherConfirmType;
private @Nullable ConfirmType publisherConfirmType;
/**
* Connection timeout. Set it to zero to wait forever.
*/
private Duration connectionTimeout;
private @Nullable Duration connectionTimeout;
/**
* Continuation timeout for RPC calls in channels. Set it to zero to wait forever.
@ -152,7 +154,7 @@ public class RabbitProperties {
private final Stream stream = new Stream();
private List<Address> parsedAddresses;
private @Nullable List<Address> parsedAddresses;
public String getHost() {
return this.host;
@ -176,7 +178,7 @@ public class RabbitProperties {
this.host = host;
}
public Integer getPort() {
public @Nullable Integer getPort() {
return this.port;
}
@ -198,11 +200,11 @@ public class RabbitProperties {
return this.parsedAddresses.get(0).port;
}
public void setPort(Integer port) {
public void setPort(@Nullable Integer port) {
this.port = port;
}
public List<String> getAddresses() {
public @Nullable List<String> getAddresses() {
return this.addresses;
}
@ -273,7 +275,7 @@ public class RabbitProperties {
* @see #setAddresses(List)
* @see #getPassword()
*/
public String determinePassword() {
public @Nullable String determinePassword() {
if (CollectionUtils.isEmpty(this.parsedAddresses)) {
return getPassword();
}
@ -289,7 +291,7 @@ public class RabbitProperties {
return this.ssl;
}
public String getVirtualHost() {
public @Nullable String getVirtualHost() {
return this.virtualHost;
}
@ -300,7 +302,7 @@ public class RabbitProperties {
* @see #setAddresses(List)
* @see #getVirtualHost()
*/
public String determineVirtualHost() {
public @Nullable String determineVirtualHost() {
if (CollectionUtils.isEmpty(this.parsedAddresses)) {
return getVirtualHost();
}
@ -308,7 +310,7 @@ public class RabbitProperties {
return (address.virtualHost != null) ? address.virtualHost : getVirtualHost();
}
public void setVirtualHost(String virtualHost) {
public void setVirtualHost(@Nullable String virtualHost) {
this.virtualHost = StringUtils.hasText(virtualHost) ? virtualHost : "/";
}
@ -320,11 +322,11 @@ public class RabbitProperties {
this.addressShuffleMode = addressShuffleMode;
}
public Duration getRequestedHeartbeat() {
public @Nullable Duration getRequestedHeartbeat() {
return this.requestedHeartbeat;
}
public void setRequestedHeartbeat(Duration requestedHeartbeat) {
public void setRequestedHeartbeat(@Nullable Duration requestedHeartbeat) {
this.requestedHeartbeat = requestedHeartbeat;
}
@ -344,19 +346,19 @@ public class RabbitProperties {
this.publisherReturns = publisherReturns;
}
public Duration getConnectionTimeout() {
public @Nullable Duration getConnectionTimeout() {
return this.connectionTimeout;
}
public void setPublisherConfirmType(ConfirmType publisherConfirmType) {
public void setPublisherConfirmType(@Nullable ConfirmType publisherConfirmType) {
this.publisherConfirmType = publisherConfirmType;
}
public ConfirmType getPublisherConfirmType() {
public @Nullable ConfirmType getPublisherConfirmType() {
return this.publisherConfirmType;
}
public void setConnectionTimeout(Duration connectionTimeout) {
public void setConnectionTimeout(@Nullable Duration connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
@ -400,17 +402,17 @@ public class RabbitProperties {
* Whether to enable SSL support. Determined automatically if an address is
* provided with the protocol (amqp:// vs. amqps://).
*/
private Boolean enabled;
private @Nullable Boolean enabled;
/**
* SSL bundle name.
*/
private String bundle;
private @Nullable String bundle;
/**
* Path to the key store that holds the SSL certificate.
*/
private String keyStore;
private @Nullable String keyStore;
/**
* Key store type.
@ -420,7 +422,7 @@ public class RabbitProperties {
/**
* Password used to access the key store.
*/
private String keyStorePassword;
private @Nullable String keyStorePassword;
/**
* Key store algorithm.
@ -430,7 +432,7 @@ public class RabbitProperties {
/**
* Trust store that holds SSL certificates.
*/
private String trustStore;
private @Nullable String trustStore;
/**
* Trust store type.
@ -440,7 +442,7 @@ public class RabbitProperties {
/**
* Password used to access the trust store.
*/
private String trustStorePassword;
private @Nullable String trustStorePassword;
/**
* Trust store algorithm.
@ -450,7 +452,7 @@ public class RabbitProperties {
/**
* SSL algorithm to use. By default, configured by the Rabbit client library.
*/
private String algorithm;
private @Nullable String algorithm;
/**
* Whether to enable server side certificate validation.
@ -462,7 +464,7 @@ public class RabbitProperties {
*/
private boolean verifyHostname = true;
public Boolean getEnabled() {
public @Nullable Boolean getEnabled() {
return this.enabled;
}
@ -482,23 +484,23 @@ public class RabbitProperties {
return address.determineSslEnabled(defaultEnabled);
}
public void setEnabled(Boolean enabled) {
public void setEnabled(@Nullable Boolean enabled) {
this.enabled = enabled;
}
public String getBundle() {
public @Nullable String getBundle() {
return this.bundle;
}
public void setBundle(String bundle) {
public void setBundle(@Nullable String bundle) {
this.bundle = bundle;
}
public String getKeyStore() {
public @Nullable String getKeyStore() {
return this.keyStore;
}
public void setKeyStore(String keyStore) {
public void setKeyStore(@Nullable String keyStore) {
this.keyStore = keyStore;
}
@ -510,11 +512,11 @@ public class RabbitProperties {
this.keyStoreType = keyStoreType;
}
public String getKeyStorePassword() {
public @Nullable String getKeyStorePassword() {
return this.keyStorePassword;
}
public void setKeyStorePassword(String keyStorePassword) {
public void setKeyStorePassword(@Nullable String keyStorePassword) {
this.keyStorePassword = keyStorePassword;
}
@ -526,11 +528,11 @@ public class RabbitProperties {
this.keyStoreAlgorithm = keyStoreAlgorithm;
}
public String getTrustStore() {
public @Nullable String getTrustStore() {
return this.trustStore;
}
public void setTrustStore(String trustStore) {
public void setTrustStore(@Nullable String trustStore) {
this.trustStore = trustStore;
}
@ -542,11 +544,11 @@ public class RabbitProperties {
this.trustStoreType = trustStoreType;
}
public String getTrustStorePassword() {
public @Nullable String getTrustStorePassword() {
return this.trustStorePassword;
}
public void setTrustStorePassword(String trustStorePassword) {
public void setTrustStorePassword(@Nullable String trustStorePassword) {
this.trustStorePassword = trustStorePassword;
}
@ -558,11 +560,11 @@ public class RabbitProperties {
this.trustStoreAlgorithm = trustStoreAlgorithm;
}
public String getAlgorithm() {
public @Nullable String getAlgorithm() {
return this.algorithm;
}
public void setAlgorithm(String sslAlgorithm) {
public void setAlgorithm(@Nullable String sslAlgorithm) {
this.algorithm = sslAlgorithm;
}
@ -604,27 +606,27 @@ public class RabbitProperties {
* Number of channels to retain in the cache. When "check-timeout" > 0, max
* channels per connection.
*/
private Integer size;
private @Nullable Integer size;
/**
* Duration to wait to obtain a channel if the cache size has been reached. If
* 0, always create a new channel.
*/
private Duration checkoutTimeout;
private @Nullable Duration checkoutTimeout;
public Integer getSize() {
public @Nullable Integer getSize() {
return this.size;
}
public void setSize(Integer size) {
public void setSize(@Nullable Integer size) {
this.size = size;
}
public Duration getCheckoutTimeout() {
public @Nullable Duration getCheckoutTimeout() {
return this.checkoutTimeout;
}
public void setCheckoutTimeout(Duration checkoutTimeout) {
public void setCheckoutTimeout(@Nullable Duration checkoutTimeout) {
this.checkoutTimeout = checkoutTimeout;
}
@ -640,7 +642,7 @@ public class RabbitProperties {
/**
* Number of connections to cache. Only applies when mode is CONNECTION.
*/
private Integer size;
private @Nullable Integer size;
public CacheMode getMode() {
return this.mode;
@ -650,11 +652,11 @@ public class RabbitProperties {
this.mode = mode;
}
public Integer getSize() {
public @Nullable Integer getSize() {
return this.size;
}
public void setSize(Integer size) {
public void setSize(@Nullable Integer size) {
this.size = size;
}
@ -744,23 +746,23 @@ public class RabbitProperties {
/**
* Acknowledge mode of container.
*/
private AcknowledgeMode acknowledgeMode;
private @Nullable AcknowledgeMode acknowledgeMode;
/**
* Maximum number of unacknowledged messages that can be outstanding at each
* consumer.
*/
private Integer prefetch;
private @Nullable Integer prefetch;
/**
* Whether rejected deliveries are re-queued by default.
*/
private Boolean defaultRequeueRejected;
private @Nullable Boolean defaultRequeueRejected;
/**
* How often idle container events should be published.
*/
private Duration idleEventInterval;
private @Nullable Duration idleEventInterval;
/**
* Whether the container should present batched messages as discrete messages or
@ -787,35 +789,35 @@ public class RabbitProperties {
this.autoStartup = autoStartup;
}
public AcknowledgeMode getAcknowledgeMode() {
public @Nullable AcknowledgeMode getAcknowledgeMode() {
return this.acknowledgeMode;
}
public void setAcknowledgeMode(AcknowledgeMode acknowledgeMode) {
public void setAcknowledgeMode(@Nullable AcknowledgeMode acknowledgeMode) {
this.acknowledgeMode = acknowledgeMode;
}
public Integer getPrefetch() {
public @Nullable Integer getPrefetch() {
return this.prefetch;
}
public void setPrefetch(Integer prefetch) {
public void setPrefetch(@Nullable Integer prefetch) {
this.prefetch = prefetch;
}
public Boolean getDefaultRequeueRejected() {
public @Nullable Boolean getDefaultRequeueRejected() {
return this.defaultRequeueRejected;
}
public void setDefaultRequeueRejected(Boolean defaultRequeueRejected) {
public void setDefaultRequeueRejected(@Nullable Boolean defaultRequeueRejected) {
this.defaultRequeueRejected = defaultRequeueRejected;
}
public Duration getIdleEventInterval() {
public @Nullable Duration getIdleEventInterval() {
return this.idleEventInterval;
}
public void setIdleEventInterval(Duration idleEventInterval) {
public void setIdleEventInterval(@Nullable Duration idleEventInterval) {
this.idleEventInterval = idleEventInterval;
}
@ -851,18 +853,18 @@ public class RabbitProperties {
/**
* Minimum number of listener invoker threads.
*/
private Integer concurrency;
private @Nullable Integer concurrency;
/**
* Maximum number of listener invoker threads.
*/
private Integer maxConcurrency;
private @Nullable Integer maxConcurrency;
/**
* Batch size, expressed as the number of physical messages, to be used by the
* container.
*/
private Integer batchSize;
private @Nullable Integer batchSize;
/**
* Whether to fail if the queues declared by the container are not available on
@ -879,27 +881,27 @@ public class RabbitProperties {
*/
private boolean consumerBatchEnabled;
public Integer getConcurrency() {
public @Nullable Integer getConcurrency() {
return this.concurrency;
}
public void setConcurrency(Integer concurrency) {
public void setConcurrency(@Nullable Integer concurrency) {
this.concurrency = concurrency;
}
public Integer getMaxConcurrency() {
public @Nullable Integer getMaxConcurrency() {
return this.maxConcurrency;
}
public void setMaxConcurrency(Integer maxConcurrency) {
public void setMaxConcurrency(@Nullable Integer maxConcurrency) {
this.maxConcurrency = maxConcurrency;
}
public Integer getBatchSize() {
public @Nullable Integer getBatchSize() {
return this.batchSize;
}
public void setBatchSize(Integer batchSize) {
public void setBatchSize(@Nullable Integer batchSize) {
this.batchSize = batchSize;
}
@ -930,7 +932,7 @@ public class RabbitProperties {
/**
* Number of consumers per queue.
*/
private Integer consumersPerQueue;
private @Nullable Integer consumersPerQueue;
/**
* Whether to fail if the queues declared by the container are not available on
@ -938,11 +940,11 @@ public class RabbitProperties {
*/
private boolean missingQueuesFatal = false;
public Integer getConsumersPerQueue() {
public @Nullable Integer getConsumersPerQueue() {
return this.consumersPerQueue;
}
public void setConsumersPerQueue(Integer consumersPerQueue) {
public void setConsumersPerQueue(@Nullable Integer consumersPerQueue) {
this.consumersPerQueue = consumersPerQueue;
}
@ -982,17 +984,17 @@ public class RabbitProperties {
/**
* Whether to enable mandatory messages.
*/
private Boolean mandatory;
private @Nullable Boolean mandatory;
/**
* Timeout for receive() operations.
*/
private Duration receiveTimeout;
private @Nullable Duration receiveTimeout;
/**
* Timeout for sendAndReceive() operations.
*/
private Duration replyTimeout;
private @Nullable Duration replyTimeout;
/**
* Name of the default exchange to use for send operations.
@ -1008,7 +1010,7 @@ public class RabbitProperties {
* Name of the default queue to receive messages from when none is specified
* explicitly.
*/
private String defaultReceiveQueue;
private @Nullable String defaultReceiveQueue;
/**
* Whether to enable observation.
@ -1018,33 +1020,33 @@ public class RabbitProperties {
/**
* Simple patterns for allowable packages/classes for deserialization.
*/
private List<String> allowedListPatterns;
private @Nullable List<String> allowedListPatterns;
public Retry getRetry() {
return this.retry;
}
public Boolean getMandatory() {
public @Nullable Boolean getMandatory() {
return this.mandatory;
}
public void setMandatory(Boolean mandatory) {
public void setMandatory(@Nullable Boolean mandatory) {
this.mandatory = mandatory;
}
public Duration getReceiveTimeout() {
public @Nullable Duration getReceiveTimeout() {
return this.receiveTimeout;
}
public void setReceiveTimeout(Duration receiveTimeout) {
public void setReceiveTimeout(@Nullable Duration receiveTimeout) {
this.receiveTimeout = receiveTimeout;
}
public Duration getReplyTimeout() {
public @Nullable Duration getReplyTimeout() {
return this.replyTimeout;
}
public void setReplyTimeout(Duration replyTimeout) {
public void setReplyTimeout(@Nullable Duration replyTimeout) {
this.replyTimeout = replyTimeout;
}
@ -1064,11 +1066,11 @@ public class RabbitProperties {
this.routingKey = routingKey;
}
public String getDefaultReceiveQueue() {
public @Nullable String getDefaultReceiveQueue() {
return this.defaultReceiveQueue;
}
public void setDefaultReceiveQueue(String defaultReceiveQueue) {
public void setDefaultReceiveQueue(@Nullable String defaultReceiveQueue) {
this.defaultReceiveQueue = defaultReceiveQueue;
}
@ -1080,11 +1082,11 @@ public class RabbitProperties {
this.observationEnabled = observationEnabled;
}
public List<String> getAllowedListPatterns() {
public @Nullable List<String> getAllowedListPatterns() {
return this.allowedListPatterns;
}
public void setAllowedListPatterns(List<String> allowedListPatterns) {
public void setAllowedListPatterns(@Nullable List<String> allowedListPatterns) {
this.allowedListPatterns = allowedListPatterns;
}
@ -1186,13 +1188,13 @@ public class RabbitProperties {
private int port;
private String username;
private @Nullable String username;
private String password;
private @Nullable String password;
private String virtualHost;
private @Nullable String virtualHost;
private Boolean secureConnection;
private @Nullable Boolean secureConnection;
private Address(String input, boolean sslEnabled) {
input = input.trim();
@ -1278,24 +1280,24 @@ public class RabbitProperties {
* Virtual host of a RabbitMQ instance with the Stream plugin enabled. When not
* set, spring.rabbitmq.virtual-host is used.
*/
private String virtualHost;
private @Nullable String virtualHost;
/**
* Login user to authenticate to the broker. When not set,
* spring.rabbitmq.username is used.
*/
private String username;
private @Nullable String username;
/**
* Login password to authenticate to the broker. When not set
* spring.rabbitmq.password is used.
*/
private String password;
private @Nullable String password;
/**
* Name of the stream.
*/
private String name;
private @Nullable String name;
public String getHost() {
return this.host;
@ -1313,35 +1315,35 @@ public class RabbitProperties {
this.port = port;
}
public String getVirtualHost() {
public @Nullable String getVirtualHost() {
return this.virtualHost;
}
public void setVirtualHost(String virtualHost) {
public void setVirtualHost(@Nullable String virtualHost) {
this.virtualHost = virtualHost;
}
public String getUsername() {
public @Nullable String getUsername() {
return this.username;
}
public void setUsername(String username) {
public void setUsername(@Nullable String username) {
this.username = username;
}
public String getPassword() {
public @Nullable String getPassword() {
return this.password;
}
public void setPassword(String password) {
public void setPassword(@Nullable String password) {
this.password = password;
}
public String getName() {
public @Nullable String getName() {
return this.name;
}
public void setName(String name) {
public void setName(@Nullable String name) {
this.name = name;
}

View File

@ -39,6 +39,7 @@ import org.springframework.rabbit.stream.producer.ProducerCustomizer;
import org.springframework.rabbit.stream.producer.RabbitStreamOperations;
import org.springframework.rabbit.stream.producer.RabbitStreamTemplate;
import org.springframework.rabbit.stream.support.converter.StreamMessageConverter;
import org.springframework.util.Assert;
/**
* Configuration for Spring RabbitMQ Stream plugin support.
@ -93,8 +94,9 @@ class RabbitStreamConfiguration {
@ConditionalOnProperty(name = "spring.rabbitmq.stream.name")
RabbitStreamTemplate rabbitStreamTemplate(Environment rabbitStreamEnvironment, RabbitProperties properties,
RabbitStreamTemplateConfigurer configurer) {
RabbitStreamTemplate template = new RabbitStreamTemplate(rabbitStreamEnvironment,
properties.getStream().getName());
String name = properties.getStream().getName();
Assert.state(name != null, "'name' must not be null");
RabbitStreamTemplate template = new RabbitStreamTemplate(rabbitStreamEnvironment, name);
configurer.configure(template);
return template;
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.amqp.autoconfigure;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.rabbit.stream.producer.ProducerCustomizer;
import org.springframework.rabbit.stream.producer.RabbitStreamTemplate;
@ -33,18 +35,18 @@ import org.springframework.rabbit.stream.support.converter.StreamMessageConverte
*/
public class RabbitStreamTemplateConfigurer {
private MessageConverter messageConverter;
private @Nullable MessageConverter messageConverter;
private StreamMessageConverter streamMessageConverter;
private @Nullable StreamMessageConverter streamMessageConverter;
private ProducerCustomizer producerCustomizer;
private @Nullable ProducerCustomizer producerCustomizer;
/**
* Set the {@link MessageConverter} to use or {@code null} if the out-of-the-box
* converter should be used.
* @param messageConverter the {@link MessageConverter}
*/
public void setMessageConverter(MessageConverter messageConverter) {
public void setMessageConverter(@Nullable MessageConverter messageConverter) {
this.messageConverter = messageConverter;
}
@ -53,7 +55,7 @@ public class RabbitStreamTemplateConfigurer {
* stream message converter should be used.
* @param streamMessageConverter the {@link StreamMessageConverter}
*/
public void setStreamMessageConverter(StreamMessageConverter streamMessageConverter) {
public void setStreamMessageConverter(@Nullable StreamMessageConverter streamMessageConverter) {
this.streamMessageConverter = streamMessageConverter;
}
@ -61,7 +63,7 @@ public class RabbitStreamTemplateConfigurer {
* Set the {@link ProducerCustomizer} instances to use.
* @param producerCustomizer the producer customizer
*/
public void setProducerCustomizer(ProducerCustomizer producerCustomizer) {
public void setProducerCustomizer(@Nullable ProducerCustomizer producerCustomizer) {
this.producerCustomizer = producerCustomizer;
}

View File

@ -19,6 +19,8 @@ package org.springframework.boot.amqp.autoconfigure;
import java.time.Duration;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter;
@ -42,9 +44,9 @@ import org.springframework.util.CollectionUtils;
*/
public class RabbitTemplateConfigurer {
private MessageConverter messageConverter;
private @Nullable MessageConverter messageConverter;
private List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
private @Nullable List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
private final RabbitProperties rabbitProperties;
@ -62,7 +64,7 @@ public class RabbitTemplateConfigurer {
* converter should be used.
* @param messageConverter the {@link MessageConverter}
*/
public void setMessageConverter(MessageConverter messageConverter) {
public void setMessageConverter(@Nullable MessageConverter messageConverter) {
this.messageConverter = messageConverter;
}
@ -70,7 +72,7 @@ public class RabbitTemplateConfigurer {
* Set the {@link RabbitRetryTemplateCustomizer} instances to use.
* @param retryTemplateCustomizers the retry template customizers
*/
public void setRetryTemplateCustomizers(List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) {
public void setRetryTemplateCustomizers(@Nullable List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers) {
this.retryTemplateCustomizers = retryTemplateCustomizers;
}

View File

@ -19,6 +19,8 @@ package org.springframework.boot.amqp.autoconfigure;
import java.time.Duration;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.retry.backoff.ExponentialBackOffPolicy;
import org.springframework.retry.policy.SimpleRetryPolicy;
@ -32,9 +34,9 @@ import org.springframework.retry.support.RetryTemplate;
*/
class RetryTemplateFactory {
private final List<RabbitRetryTemplateCustomizer> customizers;
private final @Nullable List<RabbitRetryTemplateCustomizer> customizers;
RetryTemplateFactory(List<RabbitRetryTemplateCustomizer> customizers) {
RetryTemplateFactory(@Nullable List<RabbitRetryTemplateCustomizer> customizers) {
this.customizers = customizers;
}

View File

@ -16,6 +16,8 @@
package org.springframework.boot.amqp.autoconfigure;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean;
import org.springframework.boot.ssl.SslBundle;
@ -27,7 +29,7 @@ import org.springframework.boot.ssl.SslBundle;
*/
class SslBundleRabbitConnectionFactoryBean extends RabbitConnectionFactoryBean {
private SslBundle sslBundle;
private @Nullable SslBundle sslBundle;
private boolean enableHostnameVerification;
@ -44,7 +46,7 @@ class SslBundleRabbitConnectionFactoryBean extends RabbitConnectionFactoryBean {
}
}
void setSslBundle(SslBundle sslBundle) {
void setSslBundle(@Nullable SslBundle sslBundle) {
this.sslBundle = sslBundle;
}

View File

@ -17,4 +17,7 @@
/**
* Auto-configuration for RabbitMQ health.
*/
@NullMarked
package org.springframework.boot.amqp.autoconfigure.health;
import org.jspecify.annotations.NullMarked;

View File

@ -20,6 +20,7 @@ import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.MetricsCollector;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tags;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
@ -41,7 +42,7 @@ class RabbitConnectionFactoryMetricsPostProcessor implements BeanPostProcessor,
private final ApplicationContext context;
private volatile MeterRegistry meterRegistry;
private volatile @Nullable MeterRegistry meterRegistry;
RabbitConnectionFactoryMetricsPostProcessor(ApplicationContext context) {
this.context = context;

View File

@ -17,4 +17,7 @@
/**
* Auto-configuration for RabbitMQ metrics.
*/
@NullMarked
package org.springframework.boot.amqp.autoconfigure.metrics;
import org.jspecify.annotations.NullMarked;

View File

@ -17,4 +17,7 @@
/**
* Auto-configuration for RabbitMQ.
*/
@NullMarked
package org.springframework.boot.amqp.autoconfigure;
import org.jspecify.annotations.NullMarked;

View File

@ -17,4 +17,7 @@
/**
* Support for Docker Compose RabbitMQ service connections.
*/
@NullMarked
package org.springframework.boot.amqp.docker.compose;
import org.jspecify.annotations.NullMarked;

View File

@ -16,6 +16,8 @@
package org.springframework.boot.amqp.health;
import org.jspecify.annotations.Nullable;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.health.contributor.AbstractHealthIndicator;
import org.springframework.boot.health.contributor.Health;
@ -44,9 +46,12 @@ public class RabbitHealthIndicator extends AbstractHealthIndicator {
builder.up().withDetail("version", getVersion());
}
private String getVersion() {
return this.rabbitTemplate
.execute((channel) -> channel.getConnection().getServerProperties().get("version").toString());
private @Nullable String getVersion() {
return this.rabbitTemplate.execute((channel) -> {
Object version = channel.getConnection().getServerProperties().get("version");
Assert.state(version != null, "'version' must not be null");
return version.toString();
});
}
}

View File

@ -17,4 +17,7 @@
/**
* Health integration for AMQP and RabbitMQ.
*/
@NullMarked
package org.springframework.boot.amqp.health;
import org.jspecify.annotations.NullMarked;

View File

@ -23,6 +23,7 @@ import com.rabbitmq.client.impl.MicrometerMetricsCollector;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.MeterBinder;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
@ -44,7 +45,7 @@ public class RabbitMetrics implements MeterBinder {
* @param connectionFactory the {@link ConnectionFactory} to instrument
* @param tags tags to apply to all recorded metrics
*/
public RabbitMetrics(ConnectionFactory connectionFactory, Iterable<Tag> tags) {
public RabbitMetrics(ConnectionFactory connectionFactory, @Nullable Iterable<Tag> tags) {
Assert.notNull(connectionFactory, "'connectionFactory' must not be null");
this.connectionFactory = connectionFactory;
this.tags = (tags != null) ? tags : Collections.emptyList();

View File

@ -17,4 +17,7 @@
/**
* Metrics for AMQP and RabbitMQ.
*/
@NullMarked
package org.springframework.boot.amqp.metrics;
import org.jspecify.annotations.NullMarked;

View File

@ -19,6 +19,7 @@ package org.springframework.boot.amqp.testcontainers;
import java.net.URI;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.testcontainers.containers.RabbitMQContainer;
import org.springframework.boot.amqp.autoconfigure.RabbitConnectionDetails;
@ -72,7 +73,7 @@ class RabbitContainerConnectionDetailsFactory
}
@Override
public SslBundle getSslBundle() {
public @Nullable SslBundle getSslBundle() {
return super.getSslBundle();
}

View File

@ -17,4 +17,7 @@
/**
* Support for testcontainers RabbitMQ service connections.
*/
@NullMarked
package org.springframework.boot.amqp.testcontainers;
import org.jspecify.annotations.NullMarked;