Add more @Nullable parameters based on null usage
Issue: SPR-15540
This commit is contained in:
@@ -400,7 +400,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
||||
}
|
||||
|
||||
private MessageConsumer getCachedConsumer(
|
||||
Destination dest, String selector, Boolean noLocal, String subscription, boolean durable) throws JMSException {
|
||||
Destination dest, String selector, @Nullable Boolean noLocal, @Nullable String subscription, boolean durable) throws JMSException {
|
||||
|
||||
ConsumerCacheKey cacheKey = new ConsumerCacheKey(dest, selector, noLocal, subscription, durable);
|
||||
MessageConsumer consumer = this.cachedConsumers.get(cacheKey);
|
||||
|
||||
@@ -134,7 +134,7 @@ public class JmsResourceHolder extends ResourceHolderSupport {
|
||||
addSession(session, null);
|
||||
}
|
||||
|
||||
public final void addSession(Session session, Connection connection) {
|
||||
public final void addSession(Session session, @Nullable Connection connection) {
|
||||
Assert.isTrue(!this.frozen, "Cannot add Session because JmsResourceHolder is frozen");
|
||||
Assert.notNull(session, "Session must not be null");
|
||||
if (!this.sessions.contains(session)) {
|
||||
@@ -171,7 +171,7 @@ public class JmsResourceHolder extends ResourceHolderSupport {
|
||||
return getSession(sessionType, null);
|
||||
}
|
||||
|
||||
public Session getSession(Class<? extends Session> sessionType, Connection connection) {
|
||||
public Session getSession(Class<? extends Session> sessionType, @Nullable Connection connection) {
|
||||
List<Session> sessions = this.sessions;
|
||||
if (connection != null) {
|
||||
sessions = this.sessionsPerConnection.get(connection);
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.jms.Session;
|
||||
import javax.jms.TransactionRolledBackException;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.transaction.InvalidIsolationLevelException;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
@@ -308,7 +309,7 @@ public class JmsTransactionManager extends AbstractPlatformTransactionManager
|
||||
|
||||
private JmsResourceHolder resourceHolder;
|
||||
|
||||
public void setResourceHolder(JmsResourceHolder resourceHolder) {
|
||||
public void setResourceHolder(@Nullable JmsResourceHolder resourceHolder) {
|
||||
this.resourceHolder = resourceHolder;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,8 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati
|
||||
* @param headers headers for the message to send
|
||||
* @param postProcessor the post processor to apply to the message
|
||||
*/
|
||||
void convertAndSend(String destinationName, Object payload, Map<String,
|
||||
Object> headers, MessagePostProcessor postProcessor) throws MessagingException;
|
||||
void convertAndSend(String destinationName, Object payload, @Nullable Map<String,
|
||||
Object> headers, @Nullable MessagePostProcessor postProcessor) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Receive a message from the given destination.
|
||||
@@ -153,7 +153,7 @@ public interface JmsMessageOperations extends MessageSendingOperations<Destinati
|
||||
* could not be received, for example due to a timeout
|
||||
*/
|
||||
@Nullable
|
||||
<T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers, Class<T> targetClass)
|
||||
<T> T convertSendAndReceive(String destinationName, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass)
|
||||
throws MessagingException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.jms.JmsException;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.converter.MessagingMessageConverter;
|
||||
import org.springframework.jms.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.converter.MessageConversionException;
|
||||
@@ -176,7 +177,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertAndSend(Object payload, MessagePostProcessor postProcessor) throws MessagingException {
|
||||
public void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException {
|
||||
Destination defaultDestination = getDefaultDestination();
|
||||
if (defaultDestination != null) {
|
||||
convertAndSend(defaultDestination, payload, postProcessor);
|
||||
@@ -211,8 +212,8 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertAndSend(String destinationName, Object payload, Map<String, Object> headers,
|
||||
MessagePostProcessor postProcessor) throws MessagingException {
|
||||
public void convertAndSend(String destinationName, Object payload, @Nullable Map<String, Object> headers,
|
||||
@Nullable MessagePostProcessor postProcessor) throws MessagingException {
|
||||
|
||||
Message<?> message = doConvert(payload, headers, postProcessor);
|
||||
send(destinationName, message);
|
||||
@@ -286,13 +287,13 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
|
||||
|
||||
@Override
|
||||
public <T> T convertSendAndReceive(String destinationName, Object request,
|
||||
Map<String, Object> headers, Class<T> targetClass) throws MessagingException {
|
||||
@Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingException {
|
||||
|
||||
return convertSendAndReceive(destinationName, request, headers, targetClass, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T convertSendAndReceive(Object request, Class<T> targetClass, MessagePostProcessor postProcessor) {
|
||||
public <T> T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
|
||||
Destination defaultDestination = getDefaultDestination();
|
||||
if (defaultDestination != null) {
|
||||
return convertSendAndReceive(defaultDestination, request, targetClass, postProcessor);
|
||||
@@ -311,8 +312,8 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
|
||||
Class<T> targetClass, MessagePostProcessor postProcessor) {
|
||||
public <T> T convertSendAndReceive(String destinationName, Object request, @Nullable Map<String, Object> headers,
|
||||
Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
|
||||
|
||||
Message<?> requestMessage = doConvert(request, headers, postProcessor);
|
||||
Message<?> replyMessage = sendAndReceive(destinationName, requestMessage);
|
||||
|
||||
@@ -760,7 +760,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message receiveSelected(final Destination destination, final String messageSelector) throws JmsException {
|
||||
public Message receiveSelected(final Destination destination, @Nullable final String messageSelector) throws JmsException {
|
||||
return execute(new SessionCallback<Message>() {
|
||||
@Override
|
||||
public Message doInJms(Session session) throws JMSException {
|
||||
@@ -770,7 +770,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message receiveSelected(final String destinationName, final String messageSelector) throws JmsException {
|
||||
public Message receiveSelected(final String destinationName, @Nullable final String messageSelector) throws JmsException {
|
||||
return execute(new SessionCallback<Message>() {
|
||||
@Override
|
||||
public Message doInJms(Session session) throws JMSException {
|
||||
@@ -1025,7 +1025,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T browseSelected(final Queue queue, final String messageSelector, final BrowserCallback<T> action)
|
||||
public <T> T browseSelected(final Queue queue, @Nullable final String messageSelector, final BrowserCallback<T> action)
|
||||
throws JmsException {
|
||||
|
||||
Assert.notNull(action, "Callback object must not be null");
|
||||
@@ -1044,7 +1044,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T browseSelected(final String queueName, final String messageSelector, final BrowserCallback<T> action)
|
||||
public <T> T browseSelected(final String queueName, @Nullable final String messageSelector, final BrowserCallback<T> action)
|
||||
throws JmsException {
|
||||
|
||||
Assert.notNull(action, "Callback object must not be null");
|
||||
|
||||
@@ -20,6 +20,8 @@ import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.Session;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Variant of the standard JMS {@link javax.jms.MessageListener} interface,
|
||||
* offering not only the received Message but also the underlying
|
||||
@@ -52,6 +54,6 @@ public interface SessionAwareMessageListener<M extends Message> {
|
||||
* @param session the underlying JMS Session (never {@code null})
|
||||
* @throws JMSException if thrown by JMS methods
|
||||
*/
|
||||
void onMessage(M message, Session session) throws JMSException;
|
||||
void onMessage(M message, @Nullable Session session) throws JMSException;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.jms.listener.SessionAwareMessageListener;
|
||||
import org.springframework.jms.listener.SubscriptionNameProvider;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MethodInvoker;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -195,7 +196,7 @@ public class MessageListenerAdapter extends AbstractAdaptableMessageListener imp
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onMessage(Message message, Session session) throws JMSException {
|
||||
public void onMessage(Message message, @Nullable Session session) throws JMSException {
|
||||
// Check whether the delegate is a MessageListener impl itself.
|
||||
// In that case, the adapter will simply act as a pass-through.
|
||||
Object delegate = getDelegate();
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.jms.Session;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.jms.support.JmsHeaderMapper;
|
||||
import org.springframework.jms.support.converter.MessageConversionException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.core.AbstractMessageSendingTemplate;
|
||||
@@ -61,7 +62,7 @@ public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageLis
|
||||
|
||||
|
||||
@Override
|
||||
public void onMessage(javax.jms.Message jmsMessage, Session session) throws JMSException {
|
||||
public void onMessage(javax.jms.Message jmsMessage, @Nullable Session session) throws JMSException {
|
||||
Message<?> message = toMessagingMessage(jmsMessage);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Processing [" + message + "]");
|
||||
|
||||
@@ -97,7 +97,7 @@ public class JmsInvokerServiceExporter extends RemoteInvocationBasedExporter
|
||||
|
||||
|
||||
@Override
|
||||
public void onMessage(Message requestMessage, Session session) throws JMSException {
|
||||
public void onMessage(Message requestMessage, @Nullable Session session) throws JMSException {
|
||||
RemoteInvocation invocation = readRemoteInvocation(requestMessage);
|
||||
if (invocation != null) {
|
||||
RemoteInvocationResult result = invokeAndCreateResult(invocation, this.proxy);
|
||||
|
||||
Reference in New Issue
Block a user