Fix overridden methods nullability

Issue: SPR-15869
This commit is contained in:
Sebastien Deleuze
2017-08-17 14:30:14 +02:00
parent 6b6c1d3e53
commit 73cf07e9a4
488 changed files with 1016 additions and 34 deletions

View File

@@ -83,6 +83,7 @@ public abstract class JmsException extends NestedRuntimeException {
* @see javax.jms.JMSException#getLinkedException()
*/
@Override
@Nullable
public String getMessage() {
String message = super.getMessage();
Throwable cause = getCause();

View File

@@ -103,6 +103,7 @@ abstract class AbstractListenerContainerParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
CompositeComponentDefinition compositeDef =
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));

View File

@@ -38,6 +38,7 @@ import org.springframework.util.StringUtils;
class AnnotationDrivenJmsBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);

View File

@@ -139,10 +139,12 @@ public abstract class ConnectionFactoryUtils {
return doGetTransactionalSession(cf, new ResourceFactory() {
@Override
@Nullable
public Session getSession(JmsResourceHolder holder) {
return holder.getSession(Session.class, existingCon);
}
@Override
@Nullable
public Connection getConnection(JmsResourceHolder holder) {
return (existingCon != null ? existingCon : holder.getConnection());
}
@@ -182,10 +184,12 @@ public abstract class ConnectionFactoryUtils {
return (QueueSession) doGetTransactionalSession(cf, new ResourceFactory() {
@Override
@Nullable
public Session getSession(JmsResourceHolder holder) {
return holder.getSession(QueueSession.class, existingCon);
}
@Override
@Nullable
public Connection getConnection(JmsResourceHolder holder) {
return (existingCon != null ? existingCon : holder.getConnection(QueueConnection.class));
}
@@ -225,10 +229,12 @@ public abstract class ConnectionFactoryUtils {
return (TopicSession) doGetTransactionalSession(cf, new ResourceFactory() {
@Override
@Nullable
public Session getSession(JmsResourceHolder holder) {
return holder.getSession(TopicSession.class, existingCon);
}
@Override
@Nullable
public Connection getConnection(JmsResourceHolder holder) {
return (existingCon != null ? existingCon : holder.getConnection(TopicConnection.class));
}

View File

@@ -230,6 +230,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public Message<?> receive() {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
@@ -241,6 +242,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public <T> T receiveAndConvert(Class<T> targetClass) {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
@@ -252,11 +254,13 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public Message<?> receive(String destinationName) throws MessagingException {
return doReceive(destinationName);
}
@Override
@Nullable
public <T> T receiveAndConvert(String destinationName, Class<T> targetClass) throws MessagingException {
Message<?> message = doReceive(destinationName);
if (message != null) {
@@ -268,6 +272,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public Message<?> sendAndReceive(Message<?> requestMessage) {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
@@ -279,11 +284,13 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public Message<?> sendAndReceive(String destinationName, Message<?> requestMessage) throws MessagingException {
return doSendAndReceive(destinationName, requestMessage);
}
@Override
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)
throws MessagingException {
@@ -291,11 +298,13 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public <T> T convertSendAndReceive(Object request, Class<T> targetClass) {
return convertSendAndReceive(request, targetClass, null);
}
@Override
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request,
@Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingException {
@@ -303,6 +312,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public <T> T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
@@ -314,6 +324,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass,
@Nullable MessagePostProcessor requestPostProcessor) throws MessagingException {
@@ -322,6 +333,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T convertSendAndReceive(String destinationName, Object request, @Nullable Map<String, Object> headers,
Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) {
@@ -350,6 +362,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
protected Message<?> doReceive(Destination destination) {
try {
javax.jms.Message jmsMessage = obtainJmsTemplate().receive(destination);
@@ -372,6 +385,7 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
@Nullable
protected Message<?> doSendAndReceive(Destination destination, Message<?> requestMessage) {
try {
javax.jms.Message jmsMessage = obtainJmsTemplate().sendAndReceive(

View File

@@ -463,6 +463,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
//---------------------------------------------------------------------------------------
@Override
@Nullable
public <T> T execute(SessionCallback<T> action) throws JmsException {
return execute(action, false);
}
@@ -512,6 +513,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public <T> T execute(ProducerCallback<T> action) throws JmsException {
String defaultDestinationName = getDefaultDestinationName();
if (defaultDestinationName != null) {
@@ -523,6 +525,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public <T> T execute(final @Nullable Destination destination, final ProducerCallback<T> action) throws JmsException {
Assert.notNull(action, "Callback object must not be null");
return execute(session -> {
@@ -537,6 +540,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public <T> T execute(final String destinationName, final ProducerCallback<T> action) throws JmsException {
Assert.notNull(action, "Callback object must not be null");
return execute(session -> {
@@ -700,6 +704,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
//---------------------------------------------------------------------------------------
@Override
@Nullable
public Message receive() throws JmsException {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
@@ -711,16 +716,19 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public Message receive(Destination destination) throws JmsException {
return receiveSelected(destination, null);
}
@Override
@Nullable
public Message receive(String destinationName) throws JmsException {
return receiveSelected(destinationName, null);
}
@Override
@Override@Nullable
public Message receiveSelected(String messageSelector) throws JmsException {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
@@ -732,6 +740,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public Message receiveSelected(final Destination destination, @Nullable final String messageSelector) throws JmsException {
return execute(session -> {
return doReceive(session, destination, messageSelector);
@@ -739,6 +748,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public Message receiveSelected(final String destinationName, @Nullable final String messageSelector) throws JmsException {
return execute(session -> {
Destination destination = resolveDestinationName(session, destinationName);
@@ -808,31 +818,37 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
//---------------------------------------------------------------------------------------
@Override
@Nullable
public Object receiveAndConvert() throws JmsException {
return doConvertFromMessage(receive());
}
@Override
@Nullable
public Object receiveAndConvert(Destination destination) throws JmsException {
return doConvertFromMessage(receive(destination));
}
@Override
@Nullable
public Object receiveAndConvert(String destinationName) throws JmsException {
return doConvertFromMessage(receive(destinationName));
}
@Override
@Nullable
public Object receiveSelectedAndConvert(String messageSelector) throws JmsException {
return doConvertFromMessage(receiveSelected(messageSelector));
}
@Override
@Nullable
public Object receiveSelectedAndConvert(Destination destination, String messageSelector) throws JmsException {
return doConvertFromMessage(receiveSelected(destination, messageSelector));
}
@Override
@Nullable
public Object receiveSelectedAndConvert(String destinationName, String messageSelector) throws JmsException {
return doConvertFromMessage(receiveSelected(destinationName, messageSelector));
}
@@ -861,6 +877,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
//---------------------------------------------------------------------------------------
@Override
@Nullable
public Message sendAndReceive(MessageCreator messageCreator) throws JmsException {
Destination defaultDestination = getDefaultDestination();
if (defaultDestination != null) {
@@ -872,11 +889,13 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public Message sendAndReceive(final Destination destination, final MessageCreator messageCreator) throws JmsException {
return executeLocal(session -> doSendAndReceive(session, destination, messageCreator), true);
}
@Override
@Nullable
public Message sendAndReceive(final String destinationName, final MessageCreator messageCreator) throws JmsException {
return executeLocal(session -> {
Destination destination = resolveDestinationName(session, destinationName);
@@ -955,6 +974,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
//---------------------------------------------------------------------------------------
@Override
@Nullable
public <T> T browse(BrowserCallback<T> action) throws JmsException {
Queue defaultQueue = getDefaultQueue();
if (defaultQueue != null) {
@@ -966,16 +986,19 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public <T> T browse(Queue queue, BrowserCallback<T> action) throws JmsException {
return browseSelected(queue, null, action);
}
@Override
@Nullable
public <T> T browse(String queueName, BrowserCallback<T> action) throws JmsException {
return browseSelected(queueName, null, action);
}
@Override
@Nullable
public <T> T browseSelected(String messageSelector, BrowserCallback<T> action) throws JmsException {
Queue defaultQueue = getDefaultQueue();
if (defaultQueue != null) {
@@ -987,6 +1010,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public <T> T browseSelected(final Queue queue, @Nullable final String messageSelector, final BrowserCallback<T> action)
throws JmsException {
@@ -1003,6 +1027,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
@Override
@Nullable
public <T> T browseSelected(final String queueName, @Nullable final String messageSelector, final BrowserCallback<T> action)
throws JmsException {
@@ -1145,11 +1170,13 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
private class JmsTemplateResourceFactory implements ConnectionFactoryUtils.ResourceFactory {
@Override
@Nullable
public Connection getConnection(JmsResourceHolder holder) {
return JmsTemplate.this.getConnection(holder);
}
@Override
@Nullable
public Session getSession(JmsResourceHolder holder) {
return JmsTemplate.this.getSession(holder);
}

View File

@@ -469,11 +469,13 @@ public abstract class AbstractPollingMessageListenerContainer extends AbstractMe
private class MessageListenerContainerResourceFactory implements ConnectionFactoryUtils.ResourceFactory {
@Override
@Nullable
public Connection getConnection(JmsResourceHolder holder) {
return AbstractPollingMessageListenerContainer.this.getConnection(holder);
}
@Override
@Nullable
public Session getSession(JmsResourceHolder holder) {
return AbstractPollingMessageListenerContainer.this.getSession(holder);
}

View File

@@ -256,7 +256,6 @@ public class MessageListenerAdapter extends AbstractAdaptableMessageListener imp
* @throws JMSException if thrown by JMS API methods
* @see #setDefaultListenerMethod
*/
@Nullable
protected String getListenerMethodName(Message originalMessage, Object extractedMessage) throws JMSException {
return getDefaultListenerMethod();
}

View File

@@ -191,6 +191,7 @@ public class JmsMessageEndpointManager extends GenericMessageEndpointManager
}
@Override
@Nullable
public MessageConverter getMessageConverter() {
JmsActivationSpecConfig config = getActivationSpecConfig();
if (config != null) {
@@ -200,6 +201,7 @@ public class JmsMessageEndpointManager extends GenericMessageEndpointManager
}
@Override
@Nullable
public DestinationResolver getDestinationResolver() {
if (this.activationSpecFactory instanceof StandardJmsActivationSpecFactory) {
return ((StandardJmsActivationSpecFactory) this.activationSpecFactory).getDestinationResolver();
@@ -226,6 +228,7 @@ public class JmsMessageEndpointManager extends GenericMessageEndpointManager
}
@Override
@Nullable
public QosSettings getReplyQosSettings() {
JmsActivationSpecConfig config = getActivationSpecConfig();
if (config != null) {

View File

@@ -81,6 +81,7 @@ public class JmsInvokerProxyFactoryBean extends JmsInvokerClientInterceptor
@Override
@Nullable
public Object getObject() {
return this.serviceProxy;
}