Skip to content

Commit 67ba187

Browse files
committed
Polishing
(cherry picked from commit 59a24b4)
1 parent 67f0b19 commit 67ba187

File tree

24 files changed

+152
-150
lines changed

24 files changed

+152
-150
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheInvoker.java

Lines changed: 16 additions & 13 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-2016 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.
@@ -31,14 +31,16 @@ public abstract class AbstractCacheInvoker {
3131

3232
private CacheErrorHandler errorHandler;
3333

34+
35+
protected AbstractCacheInvoker() {
36+
this(new SimpleCacheErrorHandler());
37+
}
38+
3439
protected AbstractCacheInvoker(CacheErrorHandler errorHandler) {
3540
Assert.notNull("ErrorHandler must not be null");
3641
this.errorHandler = errorHandler;
3742
}
3843

39-
protected AbstractCacheInvoker() {
40-
this(new SimpleCacheErrorHandler());
41-
}
4244

4345
/**
4446
* Set the {@link CacheErrorHandler} instance to use to handle errors
@@ -56,6 +58,7 @@ public CacheErrorHandler getErrorHandler() {
5658
return this.errorHandler;
5759
}
5860

61+
5962
/**
6063
* Execute {@link Cache#get(Object)} on the specified {@link Cache} and
6164
* invoke the error handler if an exception occurs. Return {@code null}
@@ -67,9 +70,9 @@ protected Cache.ValueWrapper doGet(Cache cache, Object key) {
6770
try {
6871
return cache.get(key);
6972
}
70-
catch (RuntimeException e) {
71-
getErrorHandler().handleCacheGetError(e, cache, key);
72-
return null; // If the exception is handled, return a cache miss
73+
catch (RuntimeException ex) {
74+
getErrorHandler().handleCacheGetError(ex, cache, key);
75+
return null; // If the exception is handled, return a cache miss
7376
}
7477
}
7578

@@ -81,8 +84,8 @@ protected void doPut(Cache cache, Object key, Object result) {
8184
try {
8285
cache.put(key, result);
8386
}
84-
catch (RuntimeException e) {
85-
getErrorHandler().handleCachePutError(e, cache, key, result);
87+
catch (RuntimeException ex) {
88+
getErrorHandler().handleCachePutError(ex, cache, key, result);
8689
}
8790
}
8891

@@ -94,8 +97,8 @@ protected void doEvict(Cache cache, Object key) {
9497
try {
9598
cache.evict(key);
9699
}
97-
catch (RuntimeException e) {
98-
getErrorHandler().handleCacheEvictError(e, cache, key);
100+
catch (RuntimeException ex) {
101+
getErrorHandler().handleCacheEvictError(ex, cache, key);
99102
}
100103
}
101104

@@ -107,8 +110,8 @@ protected void doClear(Cache cache) {
107110
try {
108111
cache.clear();
109112
}
110-
catch (RuntimeException e) {
111-
getErrorHandler().handleCacheClearError(e, cache);
113+
catch (RuntimeException ex) {
114+
getErrorHandler().handleCacheClearError(ex, cache);
112115
}
113116
}
114117

spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ private boolean hasCachePut(CacheOperationContexts contexts) {
444444
excluded.add(context);
445445
}
446446
}
447-
catch (VariableNotAvailableException e) {
447+
catch (VariableNotAvailableException ex) {
448448
// Ignoring failure due to missing result, consider the cache put has to proceed
449449
}
450450
}

spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,26 @@ public void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) {
7070
try {
7171
jmsMessage.setJMSCorrelationID((String) jmsCorrelationId);
7272
}
73-
catch (Exception e) {
74-
logger.info("failed to set JMSCorrelationID, skipping", e);
73+
catch (Exception ex) {
74+
logger.info("Failed to set JMSCorrelationID - skipping", ex);
7575
}
7676
}
7777
Destination jmsReplyTo = getHeaderIfAvailable(headers, JmsHeaders.REPLY_TO, Destination.class);
7878
if (jmsReplyTo != null) {
7979
try {
8080
jmsMessage.setJMSReplyTo(jmsReplyTo);
8181
}
82-
catch (Exception e) {
83-
logger.info("failed to set JMSReplyTo, skipping", e);
82+
catch (Exception ex) {
83+
logger.info("Failed to set JMSReplyTo - skipping", ex);
8484
}
8585
}
8686
String jmsType = getHeaderIfAvailable(headers, JmsHeaders.TYPE, String.class);
8787
if (jmsType != null) {
8888
try {
8989
jmsMessage.setJMSType(jmsType);
9090
}
91-
catch (Exception e) {
92-
logger.info("failed to set JMSType, skipping", e);
91+
catch (Exception ex) {
92+
logger.info("Failed to set JMSType - skipping", ex);
9393
}
9494
}
9595
Set<String> headerNames = headers.keySet();
@@ -101,14 +101,15 @@ public void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) {
101101
String propertyName = this.fromHeaderName(headerName);
102102
jmsMessage.setObjectProperty(propertyName, value);
103103
}
104-
catch (Exception e) {
104+
catch (Exception ex) {
105105
if (headerName.startsWith("JMSX")) {
106106
if (logger.isTraceEnabled()) {
107-
logger.trace("skipping reserved header, it cannot be set by client: " + headerName);
107+
logger.trace("Skipping reserved header '" + headerName +
108+
"' since it cannot be set by client");
108109
}
109110
}
110111
else if (logger.isWarnEnabled()) {
111-
logger.warn("failed to map Message header '" + headerName + "' to JMS property", e);
112+
logger.warn("Failed to map message header '" + headerName + "' to JMS property", ex);
112113
}
113114
}
114115
}
@@ -117,7 +118,7 @@ else if (logger.isWarnEnabled()) {
117118
}
118119
catch (Exception ex) {
119120
if (logger.isWarnEnabled()) {
120-
logger.warn("error occurred while mapping from MessageHeaders to JMS properties", ex);
121+
logger.warn("Error occurred while mapping from MessageHeaders to JMS properties", ex);
121122
}
122123
}
123124
}
@@ -133,7 +134,7 @@ public MessageHeaders toHeaders(javax.jms.Message jmsMessage) {
133134
}
134135
}
135136
catch (Exception ex) {
136-
logger.info("failed to read JMSCorrelationID property, skipping", ex);
137+
logger.info("Failed to read JMSCorrelationID property - skipping", ex);
137138
}
138139
try {
139140
Destination destination = jmsMessage.getJMSDestination();
@@ -142,21 +143,21 @@ public MessageHeaders toHeaders(javax.jms.Message jmsMessage) {
142143
}
143144
}
144145
catch (Exception ex) {
145-
logger.info("failed to read JMSDestination property, skipping", ex);
146+
logger.info("Failed to read JMSDestination property - skipping", ex);
146147
}
147148
try {
148149
int deliveryMode = jmsMessage.getJMSDeliveryMode();
149150
headers.put(JmsHeaders.DELIVERY_MODE, deliveryMode);
150151
}
151152
catch (Exception ex) {
152-
logger.info("failed to read JMSDeliveryMode property, skipping", ex);
153+
logger.info("Failed to read JMSDeliveryMode property - skipping", ex);
153154
}
154155
try {
155156
long expiration = jmsMessage.getJMSExpiration();
156157
headers.put(JmsHeaders.EXPIRATION, expiration);
157158
}
158159
catch (Exception ex) {
159-
logger.info("failed to read JMSExpiration property, skipping", ex);
160+
logger.info("Failed to read JMSExpiration property - skipping", ex);
160161
}
161162
try {
162163
String messageId = jmsMessage.getJMSMessageID();
@@ -165,13 +166,13 @@ public MessageHeaders toHeaders(javax.jms.Message jmsMessage) {
165166
}
166167
}
167168
catch (Exception ex) {
168-
logger.info("failed to read JMSMessageID property, skipping", ex);
169+
logger.info("Failed to read JMSMessageID property - skipping", ex);
169170
}
170171
try {
171172
headers.put(JmsHeaders.PRIORITY, jmsMessage.getJMSPriority());
172173
}
173174
catch (Exception ex) {
174-
logger.info("failed to read JMSPriority property, skipping", ex);
175+
logger.info("Failed to read JMSPriority property - skipping", ex);
175176
}
176177
try {
177178
Destination replyTo = jmsMessage.getJMSReplyTo();
@@ -180,13 +181,13 @@ public MessageHeaders toHeaders(javax.jms.Message jmsMessage) {
180181
}
181182
}
182183
catch (Exception ex) {
183-
logger.info("failed to read JMSReplyTo property, skipping", ex);
184+
logger.info("Failed to read JMSReplyTo property - skipping", ex);
184185
}
185186
try {
186187
headers.put(JmsHeaders.REDELIVERED, jmsMessage.getJMSRedelivered());
187188
}
188189
catch (Exception ex) {
189-
logger.info("failed to read JMSRedelivered property, skipping", ex);
190+
logger.info("Failed to read JMSRedelivered property - skipping", ex);
190191
}
191192
try {
192193
String type = jmsMessage.getJMSType();
@@ -195,13 +196,13 @@ public MessageHeaders toHeaders(javax.jms.Message jmsMessage) {
195196
}
196197
}
197198
catch (Exception ex) {
198-
logger.info("failed to read JMSType property, skipping", ex);
199+
logger.info("Failed to read JMSType property - skipping", ex);
199200
}
200201
try {
201202
headers.put(JmsHeaders.TIMESTAMP, jmsMessage.getJMSTimestamp());
202203
}
203204
catch (Exception ex) {
204-
logger.info("failed to read JMSTimestamp property, skipping", ex);
205+
logger.info("Failed to read JMSTimestamp property - skipping", ex);
205206
}
206207

207208

spring-messaging/src/main/java/org/springframework/messaging/core/GenericMessagingTemplate.java

Lines changed: 6 additions & 6 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-2016 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.
@@ -98,13 +98,13 @@ public void setThrowExceptionOnLateReply(boolean throwExceptionOnLateReply) {
9898

9999
@Override
100100
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
101-
super.setDestinationResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
101+
setDestinationResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
102102
}
103103

104104

105105
@Override
106106
protected final void doSend(MessageChannel channel, Message<?> message) {
107-
Assert.notNull(channel, "'channel' is required");
107+
Assert.notNull(channel, "MessageChannel is required");
108108

109109
MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
110110
if (accessor != null && accessor.isMutable()) {
@@ -116,13 +116,13 @@ protected final void doSend(MessageChannel channel, Message<?> message) {
116116

117117
if (!sent) {
118118
throw new MessageDeliveryException(message,
119-
"failed to send message to channel '" + channel + "' within timeout: " + timeout);
119+
"Failed to send message to channel '" + channel + "' within timeout: " + timeout);
120120
}
121121
}
122122

123123
@Override
124124
protected final Message<?> doReceive(MessageChannel channel) {
125-
Assert.notNull(channel, "'channel' is required");
125+
Assert.notNull(channel, "MessageChannel is required");
126126
Assert.state(channel instanceof PollableChannel, "A PollableChannel is required to receive messages");
127127

128128
long timeout = this.receiveTimeout;
@@ -208,7 +208,7 @@ public Message<?> receive(long timeout) {
208208
}
209209
}
210210
}
211-
catch (InterruptedException e) {
211+
catch (InterruptedException ex) {
212212
Thread.currentThread().interrupt();
213213
}
214214
return this.replyMessage;

0 commit comments

Comments
 (0)