diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java index f174cbe7e3..c43499ceae 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java @@ -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. @@ -180,9 +180,9 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache { try { return serializeValue(storeValue); } - catch (Exception ex) { - throw new IllegalArgumentException("Failed to serialize cache value '" - + userValue + "'. Does it implement Serializable?", ex); + catch (Throwable ex) { + throw new IllegalArgumentException("Failed to serialize cache value '" + userValue + + "'. Does it implement Serializable?", ex); } } else { @@ -207,9 +207,8 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache { try { return super.fromStoreValue(deserializeValue(storeValue)); } - catch (Exception ex) { - throw new IllegalArgumentException("Failed to deserialize cache value '" + - storeValue + "'", ex); + catch (Throwable ex) { + throw new IllegalArgumentException("Failed to deserialize cache value '" + storeValue + "'", ex); } } else { diff --git a/spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerEndpoint.java b/spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerEndpoint.java index d244dd2fc1..21ae508db8 100644 --- a/spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerEndpoint.java +++ b/spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerEndpoint.java @@ -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. @@ -22,12 +22,12 @@ import org.springframework.jms.listener.AbstractMessageListenerContainer; import org.springframework.jms.listener.MessageListenerContainer; import org.springframework.jms.listener.endpoint.JmsActivationSpecConfig; import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager; -import org.springframework.util.Assert; /** * Base model for a JMS listener endpoint * * @author Stephane Nicoll + * @author Juergen Hoeller * @since 4.1 * @see MethodJmsListenerEndpoint * @see SimpleJmsListenerEndpoint @@ -150,7 +150,9 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint private void setupMessageListener(MessageListenerContainer container) { MessageListener messageListener = createMessageListener(container); - Assert.state(messageListener != null, "Endpoint [" + this + "] must provide a non null message listener"); + if (messageListener == null) { + throw new IllegalStateException("Endpoint [" + this + "] must provide a non-null message listener"); + } container.setupMessageListener(messageListener); } diff --git a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java index ad476e9490..49d5eaf94e 100644 --- a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java +++ b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java @@ -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. @@ -117,8 +117,7 @@ public class JmsListenerEndpointRegistrar implements BeanFactoryAware, Initializ public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; if (beanFactory instanceof ConfigurableBeanFactory) { - ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory; - this.mutex = cbf.getSingletonMutex(); + this.mutex = ((ConfigurableBeanFactory) beanFactory).getSingletonMutex(); } } diff --git a/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java b/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java index b7379d2035..0b0bd8f280 100644 --- a/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java +++ b/spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java @@ -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. @@ -57,8 +57,6 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple private StringValueResolver embeddedValueResolver; - private BeanFactory beanFactory; - /** * Set the actual bean instance to invoke this endpoint method on. @@ -122,11 +120,10 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple } /** - * Set the {@link BeanFactory} to use to resolve expressions (can be {@code null}). + * Set the {@link BeanFactory} to use to resolve expressions (may be {@code null}). */ @Override public void setBeanFactory(BeanFactory beanFactory) { - this.beanFactory = beanFactory; if (this.embeddedValueResolver == null && beanFactory instanceof ConfigurableBeanFactory) { this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory); } diff --git a/spring-jms/src/main/java/org/springframework/jms/core/BrowserCallback.java b/spring-jms/src/main/java/org/springframework/jms/core/BrowserCallback.java index c9f2b57790..3a544cb495 100644 --- a/spring-jms/src/main/java/org/springframework/jms/core/BrowserCallback.java +++ b/spring-jms/src/main/java/org/springframework/jms/core/BrowserCallback.java @@ -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. @@ -23,8 +23,9 @@ import javax.jms.Session; /** * Callback for browsing the messages in a JMS queue. * - *
To be used with JmsTemplate's callback methods that take a BrowserCallback - * argument, often implemented as an anonymous inner class. + *
To be used with {@link JmsTemplate}'s callback methods that take a
+ * {@link BrowserCallback} argument, often implemented as an anonymous
+ * inner class or as a lambda expression.
*
* @author Juergen Hoeller
* @since 2.5.1
@@ -35,11 +36,12 @@ import javax.jms.Session;
public interface BrowserCallback The message producer is not associated with any destination.
+ * Perform operations on the given {@link javax.jms.Session} and
+ * {@link javax.jms.QueueBrowser}.
* @param session the JMS {@code Session} object to use
* @param browser the JMS {@code QueueBrowser} object to use
- * @return a result object from working with the {@code Session}, if any (can be {@code null})
+ * @return a result object from working with the {@code Session}, if any
+ * (or {@code null} if none)
* @throws javax.jms.JMSException if thrown by JMS API methods
*/
T doInJms(Session session, QueueBrowser browser) throws JMSException;
diff --git a/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java b/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java
index af787263c7..e1edfbf5b4 100644
--- a/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java
+++ b/spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java
@@ -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.
@@ -23,8 +23,9 @@ import javax.jms.Session;
/**
* Callback for sending a message to a JMS destination.
*
- * To be used with JmsTemplate's callback methods that take a ProducerCallback
- * argument, often implemented as an anonymous inner class.
+ * To be used with {@link JmsTemplate}'s callback methods that take a
+ * {@link ProducerCallback} argument, often implemented as an anonymous
+ * inner class or as a lambda expression.
*
* The typical implementation will perform multiple operations on the
* supplied JMS {@link Session} and {@link MessageProducer}.
@@ -44,7 +45,8 @@ public interface ProducerCallback To be used with the {@link JmsTemplate#execute(SessionCallback)}
- * method, often implemented as an anonymous inner class.
+ * To be used with the {@link JmsTemplate#execute(SessionCallback)} method,
+ * often implemented as an anonymous inner class or as a lambda expression.
*
* @author Mark Pollack
* @since 1.1
@@ -34,10 +33,11 @@ import javax.jms.Session;
public interface SessionCallback