Skip to content

Commit a9ae2c3

Browse files
committed
Polishing
1 parent e566e25 commit a9ae2c3

File tree

7 files changed

+37
-36
lines changed

7 files changed

+37
-36
lines changed

spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -180,9 +180,9 @@ protected Object toStoreValue(Object userValue) {
180180
try {
181181
return serializeValue(storeValue);
182182
}
183-
catch (Exception ex) {
184-
throw new IllegalArgumentException("Failed to serialize cache value '"
185-
+ userValue + "'. Does it implement Serializable?", ex);
183+
catch (Throwable ex) {
184+
throw new IllegalArgumentException("Failed to serialize cache value '" + userValue +
185+
"'. Does it implement Serializable?", ex);
186186
}
187187
}
188188
else {
@@ -207,9 +207,8 @@ protected Object fromStoreValue(Object storeValue) {
207207
try {
208208
return super.fromStoreValue(deserializeValue(storeValue));
209209
}
210-
catch (Exception ex) {
211-
throw new IllegalArgumentException("Failed to deserialize cache value '" +
212-
storeValue + "'", ex);
210+
catch (Throwable ex) {
211+
throw new IllegalArgumentException("Failed to deserialize cache value '" + storeValue + "'", ex);
213212
}
214213
}
215214
else {

spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerEndpoint.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,12 +22,12 @@
2222
import org.springframework.jms.listener.MessageListenerContainer;
2323
import org.springframework.jms.listener.endpoint.JmsActivationSpecConfig;
2424
import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager;
25-
import org.springframework.util.Assert;
2625

2726
/**
2827
* Base model for a JMS listener endpoint
2928
*
3029
* @author Stephane Nicoll
30+
* @author Juergen Hoeller
3131
* @since 4.1
3232
* @see MethodJmsListenerEndpoint
3333
* @see SimpleJmsListenerEndpoint
@@ -150,7 +150,9 @@ private void setupJmsListenerContainer(AbstractMessageListenerContainer listener
150150

151151
private void setupMessageListener(MessageListenerContainer container) {
152152
MessageListener messageListener = createMessageListener(container);
153-
Assert.state(messageListener != null, "Endpoint [" + this + "] must provide a non null message listener");
153+
if (messageListener == null) {
154+
throw new IllegalStateException("Endpoint [" + this + "] must provide a non-null message listener");
155+
}
154156
container.setupMessageListener(messageListener);
155157
}
156158

spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -117,8 +117,7 @@ public void setContainerFactoryBeanName(String containerFactoryBeanName) {
117117
public void setBeanFactory(BeanFactory beanFactory) {
118118
this.beanFactory = beanFactory;
119119
if (beanFactory instanceof ConfigurableBeanFactory) {
120-
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
121-
this.mutex = cbf.getSingletonMutex();
120+
this.mutex = ((ConfigurableBeanFactory) beanFactory).getSingletonMutex();
122121
}
123122
}
124123

spring-jms/src/main/java/org/springframework/jms/config/MethodJmsListenerEndpoint.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,8 +57,6 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple
5757

5858
private StringValueResolver embeddedValueResolver;
5959

60-
private BeanFactory beanFactory;
61-
6260

6361
/**
6462
* Set the actual bean instance to invoke this endpoint method on.
@@ -122,11 +120,10 @@ public void setEmbeddedValueResolver(StringValueResolver embeddedValueResolver)
122120
}
123121

124122
/**
125-
* Set the {@link BeanFactory} to use to resolve expressions (can be {@code null}).
123+
* Set the {@link BeanFactory} to use to resolve expressions (may be {@code null}).
126124
*/
127125
@Override
128126
public void setBeanFactory(BeanFactory beanFactory) {
129-
this.beanFactory = beanFactory;
130127
if (this.embeddedValueResolver == null && beanFactory instanceof ConfigurableBeanFactory) {
131128
this.embeddedValueResolver = new EmbeddedValueResolver((ConfigurableBeanFactory) beanFactory);
132129
}

spring-jms/src/main/java/org/springframework/jms/core/BrowserCallback.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,9 @@
2323
/**
2424
* Callback for browsing the messages in a JMS queue.
2525
*
26-
* <p>To be used with JmsTemplate's callback methods that take a BrowserCallback
27-
* argument, often implemented as an anonymous inner class.
26+
* <p>To be used with {@link JmsTemplate}'s callback methods that take a
27+
* {@link BrowserCallback} argument, often implemented as an anonymous
28+
* inner class or as a lambda expression.
2829
*
2930
* @author Juergen Hoeller
3031
* @since 2.5.1
@@ -35,11 +36,12 @@
3536
public interface BrowserCallback<T> {
3637

3738
/**
38-
* Perform operations on the given {@link javax.jms.Session} and {@link javax.jms.QueueBrowser}.
39-
* <p>The message producer is not associated with any destination.
39+
* Perform operations on the given {@link javax.jms.Session} and
40+
* {@link javax.jms.QueueBrowser}.
4041
* @param session the JMS {@code Session} object to use
4142
* @param browser the JMS {@code QueueBrowser} object to use
42-
* @return a result object from working with the {@code Session}, if any (can be {@code null})
43+
* @return a result object from working with the {@code Session}, if any
44+
* (or {@code null} if none)
4345
* @throws javax.jms.JMSException if thrown by JMS API methods
4446
*/
4547
T doInJms(Session session, QueueBrowser browser) throws JMSException;

spring-jms/src/main/java/org/springframework/jms/core/ProducerCallback.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,9 @@
2323
/**
2424
* Callback for sending a message to a JMS destination.
2525
*
26-
* <p>To be used with JmsTemplate's callback methods that take a ProducerCallback
27-
* argument, often implemented as an anonymous inner class.
26+
* <p>To be used with {@link JmsTemplate}'s callback methods that take a
27+
* {@link ProducerCallback} argument, often implemented as an anonymous
28+
* inner class or as a lambda expression.
2829
*
2930
* <p>The typical implementation will perform multiple operations on the
3031
* supplied JMS {@link Session} and {@link MessageProducer}.
@@ -44,7 +45,8 @@ public interface ProducerCallback<T> {
4445
* when specified in the JmsTemplate call.
4546
* @param session the JMS {@code Session} object to use
4647
* @param producer the JMS {@code MessageProducer} object to use
47-
* @return a result object from working with the {@code Session}, if any (can be {@code null})
48+
* @return a result object from working with the {@code Session}, if any
49+
* (or {@code null} if none)
4850
* @throws javax.jms.JMSException if thrown by JMS API methods
4951
*/
5052
T doInJms(Session session, MessageProducer producer) throws JMSException;

spring-jms/src/main/java/org/springframework/jms/core/SessionCallback.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,11 +20,10 @@
2020
import javax.jms.Session;
2121

2222
/**
23-
* Callback for executing any number of operations on a provided
24-
* {@link Session}.
23+
* Callback for executing any number of operations on a provided {@link Session}.
2524
*
26-
* <p>To be used with the {@link JmsTemplate#execute(SessionCallback)}
27-
* method, often implemented as an anonymous inner class.
25+
* <p>To be used with the {@link JmsTemplate#execute(SessionCallback)} method,
26+
* often implemented as an anonymous inner class or as a lambda expression.
2827
*
2928
* @author Mark Pollack
3029
* @since 1.1
@@ -34,10 +33,11 @@
3433
public interface SessionCallback<T> {
3534

3635
/**
37-
* Execute any number of operations against the supplied JMS
38-
* {@link Session}, possibly returning a result.
36+
* Execute any number of operations against the supplied JMS {@link Session},
37+
* possibly returning a result.
3938
* @param session the JMS {@code Session}
40-
* @return a result object from working with the {@code Session}, if any (so can be {@code null})
39+
* @return a result object from working with the {@code Session}, if any
40+
* (or {@code null} if none)
4141
* @throws javax.jms.JMSException if thrown by JMS API methods
4242
*/
4343
T doInJms(Session session) throws JMSException;

0 commit comments

Comments
 (0)