Skip to content

Commit 473ed1a

Browse files
committed
Polishing
1 parent cc02269 commit 473ed1a

File tree

6 files changed

+33
-36
lines changed

6 files changed

+33
-36
lines changed

spring-context-support/src/main/java/org/springframework/mail/javamail/InternetAddressEditor.java

Lines changed: 1 addition & 2 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-2014 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.
@@ -17,7 +17,6 @@
1717
package org.springframework.mail.javamail;
1818

1919
import java.beans.PropertyEditorSupport;
20-
2120
import javax.mail.internet.AddressException;
2221
import javax.mail.internet.InternetAddress;
2322

spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMailMessage.java

Lines changed: 1 addition & 2 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-2014 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.
@@ -17,7 +17,6 @@
1717
package org.springframework.mail.javamail;
1818

1919
import java.util.Date;
20-
2120
import javax.mail.MessagingException;
2221
import javax.mail.internet.MimeMessage;
2322

spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -38,7 +38,6 @@
3838
import org.springframework.util.Assert;
3939
import org.springframework.util.CollectionUtils;
4040

41-
4241
/**
4342
* Abstract base class for a {@link MessageHandler} that broker messages to
4443
* registered subscribers.
@@ -51,7 +50,6 @@ public abstract class AbstractBrokerMessageHandler
5150

5251
protected final Log logger = LogFactory.getLog(getClass());
5352

54-
5553
private final SubscribableChannel clientInboundChannel;
5654

5755
private final MessageChannel clientOutboundChannel;
@@ -74,7 +72,7 @@ public abstract class AbstractBrokerMessageHandler
7472

7573
private final Object lifecycleMonitor = new Object();
7674

77-
private ChannelInterceptor unsentDisconnectInterceptor = new UnsentDisconnectChannelInterceptor();
75+
private final ChannelInterceptor unsentDisconnectInterceptor = new UnsentDisconnectChannelInterceptor();
7876

7977

8078
/**
@@ -151,18 +149,6 @@ public int getPhase() {
151149
return Integer.MAX_VALUE;
152150
}
153151

154-
/**
155-
* Check whether this message handler is currently running.
156-
* <p>Note that even when this message handler is running the
157-
* {@link #isBrokerAvailable()} flag may still independently alternate between
158-
* being on and off depending on the concrete sub-class implementation.
159-
*/
160-
@Override
161-
public final boolean isRunning() {
162-
synchronized (this.lifecycleMonitor) {
163-
return this.running;
164-
}
165-
}
166152

167153
@Override
168154
public void start() {
@@ -177,9 +163,7 @@ public void start() {
177163
}
178164
startInternal();
179165
this.running = true;
180-
if (logger.isInfoEnabled()) {
181-
logger.info("Started.");
182-
}
166+
logger.info("Started.");
183167
}
184168
}
185169

@@ -199,9 +183,7 @@ public void stop() {
199183
((InterceptableChannel) this.clientInboundChannel).removeInterceptor(this.unsentDisconnectInterceptor);
200184
}
201185
this.running = false;
202-
if (logger.isDebugEnabled()) {
203-
logger.info("Stopped.");
204-
}
186+
logger.info("Stopped.");
205187
}
206188
}
207189

@@ -216,6 +198,19 @@ public final void stop(Runnable callback) {
216198
}
217199
}
218200

201+
/**
202+
* Check whether this message handler is currently running.
203+
* <p>Note that even when this message handler is running the
204+
* {@link #isBrokerAvailable()} flag may still independently alternate between
205+
* being on and off depending on the concrete sub-class implementation.
206+
*/
207+
@Override
208+
public final boolean isRunning() {
209+
synchronized (this.lifecycleMonitor) {
210+
return this.running;
211+
}
212+
}
213+
219214
/**
220215
* Whether the message broker is currently available and able to process messages.
221216
* <p>Note that this is in addition to the {@link #isRunning()} flag, which
@@ -245,6 +240,7 @@ public void handleMessage(Message<?> message) {
245240

246241
protected abstract void handleMessageInternal(Message<?> message);
247242

243+
248244
protected boolean checkDestinationPrefix(String destination) {
249245
if ((destination == null) || CollectionUtils.isEmpty(this.destinationPrefixes)) {
250246
return true;
@@ -294,4 +290,5 @@ public void afterSendCompletion(Message<?> message, MessageChannel channel, bool
294290
}
295291
}
296292
}
293+
297294
}

spring-messaging/src/main/java/org/springframework/messaging/support/ChannelInterceptor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public interface ChannelInterceptor {
4747
/**
4848
* Invoked after the completion of a send regardless of any exception that
4949
* have been raised thus allowing for proper resource cleanup.
50-
* <p>Note that this will be invoked only if preSend successfully completed
51-
* and returned a Message, i.e. it did not return {@code null}.
50+
* <p>Note that this will be invoked only if {@link #preSend} successfully
51+
* completed and returned a Message, i.e. it did not return {@code null}.
5252
* @since 4.1
5353
*/
5454
void afterSendCompletion(Message<?> message, MessageChannel channel, boolean sent, Exception ex);
@@ -70,7 +70,7 @@ public interface ChannelInterceptor {
7070
/**
7171
* Invoked after the completion of a receive regardless of any exception that
7272
* have been raised thus allowing for proper resource cleanup.
73-
* <p>Note that this will be invoked only if preReceive successfully
73+
* <p>Note that this will be invoked only if {@link #preReceive} successfully
7474
* completed and returned {@code true}.
7575
* @since 4.1
7676
*/

spring-messaging/src/main/java/org/springframework/messaging/support/InterceptableChannel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.messaging.support;
1718

1819
import java.util.List;

spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -33,6 +33,7 @@
3333

3434
/**
3535
* Test fixture for the use of {@link ChannelInterceptor}s.
36+
*
3637
* @author Rossen Stoyanchev
3738
*/
3839
public class ChannelInterceptorTests {
@@ -184,26 +185,25 @@ public void afterCompletionWithPreSendException() {
184185

185186
private static class TestMessageHandler implements MessageHandler {
186187

187-
private List<Message<?>> messages = new ArrayList<Message<?>>();
188-
188+
private final List<Message<?>> messages = new ArrayList<Message<?>>();
189189

190190
public List<Message<?>> getMessages() {
191191
return this.messages;
192192
}
193193

194194
@Override
195195
public void handleMessage(Message<?> message) throws MessagingException {
196-
this.getMessages().add(message);
196+
this.messages.add(message);
197197
}
198198
}
199199

200+
200201
private abstract static class AbstractTestInterceptor extends ChannelInterceptorAdapter {
201202

202203
private AtomicInteger counter = new AtomicInteger();
203204

204205
private volatile boolean afterCompletionInvoked;
205206

206-
207207
public AtomicInteger getCounter() {
208208
return this.counter;
209209
}
@@ -225,13 +225,13 @@ public void afterSendCompletion(Message<?> message, MessageChannel channel, bool
225225
}
226226
}
227227

228+
228229
private static class PreSendInterceptor extends AbstractTestInterceptor {
229230

230231
private Message<?> messageToReturn;
231232

232233
private RuntimeException exceptionToRaise;
233234

234-
235235
public void setMessageToReturn(Message<?> messageToReturn) {
236236
this.messageToReturn = messageToReturn;
237237
}
@@ -250,6 +250,7 @@ public Message<?> preSend(Message<?> message, MessageChannel channel) {
250250
}
251251
}
252252

253+
253254
private static class NullReturningPreSendInterceptor extends AbstractTestInterceptor {
254255

255256
@Override

0 commit comments

Comments
 (0)