Skip to content

Commit fcfacd9

Browse files
committed
Polishing
(cherry picked from commit f095aa2)
1 parent bddcc66 commit fcfacd9

File tree

17 files changed

+221
-224
lines changed

17 files changed

+221
-224
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.
@@ -186,9 +186,9 @@ protected Object toStoreValue(Object userValue) {
186186
try {
187187
return serializeValue(storeValue);
188188
}
189-
catch (Exception ex) {
190-
throw new IllegalArgumentException("Failed to serialize cache value '"
191-
+ userValue + "'. Does it implement Serializable?", ex);
189+
catch (Throwable ex) {
190+
throw new IllegalArgumentException("Failed to serialize cache value '" + userValue +
191+
"'. Does it implement Serializable?", ex);
192192
}
193193
}
194194
else {
@@ -213,9 +213,8 @@ protected Object fromStoreValue(Object storeValue) {
213213
try {
214214
return super.fromStoreValue(deserializeValue(storeValue));
215215
}
216-
catch (Exception ex) {
217-
throw new IllegalArgumentException("Failed to deserialize cache value '" +
218-
storeValue + "'", ex);
216+
catch (Throwable ex) {
217+
throw new IllegalArgumentException("Failed to deserialize cache value '" + storeValue + "'", ex);
219218
}
220219
}
221220
else {

spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java

Lines changed: 1 addition & 1 deletion
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.

spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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,11 @@
2222
import java.util.List;
2323

2424
/**
25-
* ParameterNameDiscoverer implementation that tries several ParameterNameDiscoverers
26-
* in succession. Those added first in the {@code addDiscoverer} method have
27-
* highest priority. If one returns {@code null}, the next will be tried.
25+
* {@link ParameterNameDiscoverer} implementation that tries several discoverer
26+
* delegates in succession. Those added first in the {@code addDiscoverer} method
27+
* have highest priority. If one returns {@code null}, the next will be tried.
2828
*
29-
* <p>The default behavior is always to return {@code null}
30-
* if no discoverer matches.
29+
* <p>The default behavior is to return {@code null} if no discoverer matches.
3130
*
3231
* @author Rod Johnson
3332
* @author Juergen Hoeller
@@ -40,8 +39,8 @@ public class PrioritizedParameterNameDiscoverer implements ParameterNameDiscover
4039

4140

4241
/**
43-
* Add a further ParameterNameDiscoverer to the list of discoverers
44-
* that this PrioritizedParameterNameDiscoverer checks.
42+
* Add a further {@link ParameterNameDiscoverer} delegate to the list of
43+
* discoverers that this {@code PrioritizedParameterNameDiscoverer} checks.
4544
*/
4645
public void addDiscoverer(ParameterNameDiscoverer pnd) {
4746
this.parameterNameDiscoverers.add(pnd);

spring-core/src/main/java/org/springframework/core/StandardReflectionParameterNameDiscoverer.java

Lines changed: 2 additions & 1 deletion
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.
@@ -28,6 +28,7 @@
2828
*
2929
* @author Juergen Hoeller
3030
* @since 4.0
31+
* @see java.lang.reflect.Method#getParameters()
3132
* @see java.lang.reflect.Parameter#getName()
3233
*/
3334
@UsesJava8

spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -35,9 +35,9 @@
3535
*/
3636
public class ConvertingComparator<S, T> implements Comparator<S> {
3737

38-
private Comparator<T> comparator;
38+
private final Comparator<T> comparator;
3939

40-
private Converter<S, T> converter;
40+
private final Converter<S, T> converter;
4141

4242

4343
/**

spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 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.
@@ -27,7 +27,7 @@
2727
@SuppressWarnings("serial")
2828
public class InvalidMimeTypeException extends IllegalArgumentException {
2929

30-
private String mimeType;
30+
private final String mimeType;
3131

3232

3333
/**
@@ -38,7 +38,6 @@ public class InvalidMimeTypeException extends IllegalArgumentException {
3838
public InvalidMimeTypeException(String mimeType, String message) {
3939
super("Invalid mime type \"" + mimeType + "\": " + message);
4040
this.mimeType = mimeType;
41-
4241
}
4342

4443

spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -37,7 +37,7 @@
3737
* @author Juergen Hoeller
3838
* @since 1.2.2
3939
*/
40-
@SuppressWarnings({ "serial", "rawtypes" })
40+
@SuppressWarnings({"serial", "rawtypes"})
4141
public class CompoundComparator<T> implements Comparator<T>, Serializable {
4242

4343
private final List<InvertibleComparator> comparators;
@@ -64,7 +64,7 @@ public CompoundComparator(Comparator... comparators) {
6464
Assert.notNull(comparators, "Comparators must not be null");
6565
this.comparators = new ArrayList<InvertibleComparator>(comparators.length);
6666
for (Comparator comparator : comparators) {
67-
this.addComparator(comparator);
67+
addComparator(comparator);
6868
}
6969
}
7070

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.
@@ -118,8 +118,7 @@ public void setContainerFactoryBeanName(String containerFactoryBeanName) {
118118
public void setBeanFactory(BeanFactory beanFactory) {
119119
this.beanFactory = beanFactory;
120120
if (beanFactory instanceof ConfigurableBeanFactory) {
121-
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
122-
this.mutex = cbf.getSingletonMutex();
121+
this.mutex = ((ConfigurableBeanFactory) beanFactory).getSingletonMutex();
123122
}
124123
}
125124

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-2012 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
@@ -34,11 +35,12 @@
3435
public interface BrowserCallback<T> {
3536

3637
/**
37-
* Perform operations on the given {@link javax.jms.Session} and {@link javax.jms.QueueBrowser}.
38-
* <p>The message producer is not associated with any destination.
38+
* Perform operations on the given {@link javax.jms.Session} and
39+
* {@link javax.jms.QueueBrowser}.
3940
* @param session the JMS {@code Session} object to use
4041
* @param browser the JMS {@code QueueBrowser} object to use
41-
* @return a result object from working with the {@code Session}, if any (can be {@code null})
42+
* @return a result object from working with the {@code Session}, if any
43+
* (or {@code null} if none)
4244
* @throws javax.jms.JMSException if thrown by JMS API methods
4345
*/
4446
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-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.
@@ -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}.
@@ -43,7 +44,8 @@ public interface ProducerCallback<T> {
4344
* when specified in the JmsTemplate call.
4445
* @param session the JMS {@code Session} object to use
4546
* @param producer the JMS {@code MessageProducer} object to use
46-
* @return a result object from working with the {@code Session}, if any (can be {@code null})
47+
* @return a result object from working with the {@code Session}, if any
48+
* (or {@code null} if none)
4749
* @throws javax.jms.JMSException if thrown by JMS API methods
4850
*/
4951
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-2012 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
@@ -33,10 +32,11 @@
3332
public interface SessionCallback<T> {
3433

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

0 commit comments

Comments
 (0)