Backport further refinements from the nullability efforts
Issue: SPR-15656
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -151,15 +151,14 @@ abstract class AbstractListenerContainerParser implements BeanDefinitionParser {
|
||||
listenerDef.getPropertyValues().add("delegate", new RuntimeBeanReference(ref));
|
||||
}
|
||||
|
||||
String method = null;
|
||||
if (listenerEle.hasAttribute(METHOD_ATTRIBUTE)) {
|
||||
method = listenerEle.getAttribute(METHOD_ATTRIBUTE);
|
||||
String method = listenerEle.getAttribute(METHOD_ATTRIBUTE);
|
||||
if (!StringUtils.hasText(method)) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Listener 'method' attribute contains empty value.", listenerEle);
|
||||
}
|
||||
listenerDef.getPropertyValues().add("defaultListenerMethod", method);
|
||||
}
|
||||
listenerDef.getPropertyValues().add("defaultListenerMethod", method);
|
||||
|
||||
PropertyValue messageConverterPv = commonContainerProperties.getPropertyValue("messageConverter");
|
||||
if (messageConverterPv != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -170,10 +170,7 @@ public class JmsResourceHolder extends ResourceHolderSupport {
|
||||
}
|
||||
|
||||
public Session getSession(Class<? extends Session> sessionType, Connection connection) {
|
||||
List<Session> sessions = this.sessions;
|
||||
if (connection != null) {
|
||||
sessions = this.sessionsPerConnection.get(connection);
|
||||
}
|
||||
List<Session> sessions = (connection != null ? this.sessionsPerConnection.get(connection) : this.sessions);
|
||||
return CollectionUtils.findValueOfType(sessions, sessionType);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ public class JmsTransactionManager extends AbstractPlatformTransactionManager
|
||||
@Override
|
||||
protected boolean isExistingTransaction(Object transaction) {
|
||||
JmsTransactionObject txObject = (JmsTransactionObject) transaction;
|
||||
return (txObject.getResourceHolder() != null);
|
||||
return txObject.hasResourceHolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,6 +316,10 @@ public class JmsTransactionManager extends AbstractPlatformTransactionManager
|
||||
return this.resourceHolder;
|
||||
}
|
||||
|
||||
public boolean hasResourceHolder() {
|
||||
return (this.resourceHolder != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRollbackOnly() {
|
||||
return this.resourceHolder.isRollbackOnly();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -197,7 +197,6 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen
|
||||
* @see #setDestinationName(String)
|
||||
*/
|
||||
public void setDestination(Destination destination) {
|
||||
Assert.notNull(destination, "'destination' must not be null");
|
||||
this.destination = destination;
|
||||
if (destination instanceof Topic && !(destination instanceof Queue)) {
|
||||
// Clearly a Topic: let's set the "pubSubDomain" flag accordingly.
|
||||
@@ -223,11 +222,9 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen
|
||||
* container picking up the new destination immediately (works e.g. with
|
||||
* DefaultMessageListenerContainer, as long as the cache level is less than
|
||||
* CACHE_CONSUMER). However, this is considered advanced usage; use it with care!
|
||||
* @param destinationName the desired destination (can be {@code null})
|
||||
* @see #setDestination(javax.jms.Destination)
|
||||
*/
|
||||
public void setDestinationName(String destinationName) {
|
||||
Assert.notNull(destinationName, "'destinationName' must not be null");
|
||||
this.destination = destinationName;
|
||||
}
|
||||
|
||||
@@ -246,7 +243,8 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen
|
||||
* (never {@code null}).
|
||||
*/
|
||||
protected String getDestinationDescription() {
|
||||
return this.destination.toString();
|
||||
Object destination = this.destination;
|
||||
return (destination != null ? destination.toString() : "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,7 +430,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen
|
||||
*/
|
||||
public void setDurableSubscriptionName(String durableSubscriptionName) {
|
||||
this.subscriptionName = durableSubscriptionName;
|
||||
this.subscriptionDurable = true;
|
||||
this.subscriptionDurable = (durableSubscriptionName != null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -191,6 +191,9 @@ public abstract class AbstractAdaptableMessageListener
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void onMessage(Message message, Session session) throws JMSException;
|
||||
|
||||
/**
|
||||
* Handle the given exception that arose during listener execution.
|
||||
* The default implementation logs the exception at error level.
|
||||
@@ -204,6 +207,7 @@ public abstract class AbstractAdaptableMessageListener
|
||||
logger.error("Listener execution failed", ex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract the message body from the given JMS message.
|
||||
* @param message the JMS {@code Message}
|
||||
@@ -453,6 +457,7 @@ public abstract class AbstractAdaptableMessageListener
|
||||
@Override
|
||||
protected Message createMessageForPayload(Object payload, Session session, Object conversionHint)
|
||||
throws JMSException {
|
||||
|
||||
MessageConverter converter = getMessageConverter();
|
||||
if (converter == null) {
|
||||
throw new IllegalStateException("No message converter, cannot handle '" + payload + "'");
|
||||
@@ -464,6 +469,7 @@ public abstract class AbstractAdaptableMessageListener
|
||||
return converter.toMessage(payload, session);
|
||||
}
|
||||
|
||||
|
||||
protected class LazyResolutionMessage implements org.springframework.messaging.Message<Object> {
|
||||
|
||||
private final javax.jms.Message message;
|
||||
@@ -487,7 +493,6 @@ public abstract class AbstractAdaptableMessageListener
|
||||
"Failed to extract payload from [" + this.message + "]", ex);
|
||||
}
|
||||
}
|
||||
//
|
||||
return this.payload;
|
||||
}
|
||||
|
||||
@@ -513,7 +518,6 @@ public abstract class AbstractAdaptableMessageListener
|
||||
return this.headers;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -94,7 +94,7 @@ public class StandardJmsActivationSpecFactory implements JmsActivationSpecFactor
|
||||
* Return the {@link DestinationResolver} to use for resolving destinations names.
|
||||
*/
|
||||
public DestinationResolver getDestinationResolver() {
|
||||
return destinationResolver;
|
||||
return this.destinationResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user