Skip to content

Commit 0706889

Browse files
committed
Polishing
(cherry picked from commit 058714b)
1 parent 25644db commit 0706889

File tree

12 files changed

+90
-80
lines changed

12 files changed

+90
-80
lines changed

spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java

Lines changed: 4 additions & 1 deletion
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-2015 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.
@@ -394,6 +394,8 @@ private class MessageSourceControl extends ResourceBundle.Control {
394394
@Override
395395
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
396396
throws IllegalAccessException, InstantiationException, IOException {
397+
398+
// Special handling of default encoding
397399
if (format.equals("java.properties")) {
398400
String bundleName = toBundleName(baseName, locale);
399401
final String resourceName = toResourceName(bundleName, "properties");
@@ -441,6 +443,7 @@ public InputStream run() throws IOException {
441443
}
442444
}
443445
else {
446+
// Delegate handling of "java.class" format to standard Control
444447
return super.newBundle(baseName, locale, format, loader, reload);
445448
}
446449
}

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

Lines changed: 6 additions & 7 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-2015 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,11 +22,10 @@
2222
import java.util.UUID;
2323

2424
/**
25-
* An {@link org.springframework.util.IdGenerator IdGenerator} that uses
26-
* {@link SecureRandom} for the initial seed and {@link Random} thereafter
27-
* instead of calling {@link UUID#randomUUID()} every time as
28-
* {@link org.springframework.util.JdkIdGenerator JdkIdGenerator} does.
29-
* This provides a better balance between securely random id's and performance.
25+
* An {@link IdGenerator} that uses {@link SecureRandom} for the initial seed and
26+
* {@link Random} thereafter, instead of calling {@link UUID#randomUUID()} every
27+
* time as {@link org.springframework.util.JdkIdGenerator JdkIdGenerator} does.
28+
* This provides a better balance between securely random ids and performance.
3029
*
3130
* @author Rossen Stoyanchev
3231
* @author Rob Winch
@@ -45,8 +44,8 @@ public AlternativeJdkIdGenerator() {
4544
}
4645

4746

47+
@Override
4848
public UUID generateId() {
49-
5049
byte[] randomBytes = new byte[16];
5150
this.random.nextBytes(randomBytes);
5251

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

Lines changed: 4 additions & 4 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-2015 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.
@@ -19,14 +19,14 @@
1919
import java.util.UUID;
2020

2121
/**
22-
* An IdGenerator that calls {@link java.util.UUID#randomUUID()}.
22+
* An {@link IdGenerator} that calls {@link java.util.UUID#randomUUID()}.
2323
*
2424
* @author Rossen Stoyanchev
25-
* @since 4.2
25+
* @since 4.1.5
2626
*/
2727
public class JdkIdGenerator implements IdGenerator {
2828

29-
29+
@Override
3030
public UUID generateId() {
3131
return UUID.randomUUID();
3232
}

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

Lines changed: 3 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-2015 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,10 +20,10 @@
2020
import java.util.concurrent.atomic.AtomicLong;
2121

2222
/**
23-
* An simple IdGenerator that starts at 1 and increments by 1 with each call.
23+
* A simple {@link IdGenerator} that starts at 1 and increments by 1 with each call.
2424
*
2525
* @author Rossen Stoyanchev
26-
* @since 4.2
26+
* @since 4.1.5
2727
*/
2828
public class SimpleIdGenerator implements IdGenerator {
2929

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractMethodArgumentResolutionException.java

Lines changed: 7 additions & 7 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-2015 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.
@@ -42,23 +42,23 @@ protected AbstractMethodArgumentResolutionException(Message<?> message, MethodPa
4242

4343
/**
4444
* Create a new instance providing the invalid {@code MethodParameter} and
45-
* a prepared description. Sub-classes should prepend the description with
45+
* a prepared description. Subclasses should prepend the description with
4646
* the help of {@link #getMethodParamMessage(org.springframework.core.MethodParameter)}.
4747
*/
48-
protected AbstractMethodArgumentResolutionException(Message<?> message,
49-
MethodParameter parameter, String description) {
50-
48+
protected AbstractMethodArgumentResolutionException(Message<?> message, MethodParameter param, String description) {
5149
super(message, description);
52-
this.parameter = parameter;
50+
this.parameter = param;
5351
}
5452

53+
5554
/**
5655
* Return the MethodParameter that was rejected.
5756
*/
58-
public MethodParameter getMethodParameter() {
57+
public final MethodParameter getMethodParameter() {
5958
return this.parameter;
6059
}
6160

61+
6262
protected static String getMethodParamMessage(MethodParameter param) {
6363
return new StringBuilder("Could not resolve method parameter at index ")
6464
.append(param.getParameterIndex()).append(" in method: ")

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/MethodArgumentNotValidException.java

Lines changed: 6 additions & 7 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-2015 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.
@@ -49,22 +49,21 @@ public MethodArgumentNotValidException(Message<?> message, MethodParameter param
4949
public MethodArgumentNotValidException(Message<?> message, MethodParameter parameter,
5050
BindingResult bindingResult) {
5151

52-
super(message, parameter, getMethodParamMessage(parameter) +
53-
getValidationErrorMessage(parameter, bindingResult));
54-
52+
super(message, parameter, getMethodParamMessage(parameter) + getValidationErrorMessage(bindingResult));
5553
this.bindingResult = bindingResult;
5654
}
5755

5856

5957
/**
60-
* Return the BindingResult if the failure is validation-related or {@code null}.
58+
* Return the BindingResult if the failure is validation-related,
59+
* or {@code null} if none.
6160
*/
62-
public BindingResult getBindingResult() {
61+
public final BindingResult getBindingResult() {
6362
return this.bindingResult;
6463
}
6564

6665

67-
private static String getValidationErrorMessage(MethodParameter parameter, BindingResult bindingResult) {
66+
private static String getValidationErrorMessage(BindingResult bindingResult) {
6867
if (bindingResult != null) {
6968
StringBuilder sb = new StringBuilder();
7069
sb.append(", with ").append(bindingResult.getErrorCount()).append(" error(s): ");

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/MethodArgumentTypeMismatchException.java

Lines changed: 4 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-2015 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.
@@ -29,11 +29,11 @@
2929
@SuppressWarnings("serial")
3030
public class MethodArgumentTypeMismatchException extends AbstractMethodArgumentResolutionException {
3131

32-
3332
/**
3433
* Create a new instance with the invalid {@code MethodParameter}.
3534
*/
36-
public MethodArgumentTypeMismatchException(Message<?> message, MethodParameter parameter, String description) {
37-
super(message, parameter, getMethodParamMessage(parameter) + description);
35+
public MethodArgumentTypeMismatchException(Message<?> message, MethodParameter param, String description) {
36+
super(message, param, getMethodParamMessage(param) + description);
3837
}
38+
3939
}

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolver.java

Lines changed: 7 additions & 7 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-2015 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,8 +20,8 @@
2020
import org.springframework.messaging.Message;
2121

2222
/**
23-
* Strategy interface for resolving method parameters into argument values in
24-
* the context of a given {@link Message}.
23+
* Strategy interface for resolving method parameters into argument values
24+
* in the context of a given {@link Message}.
2525
*
2626
* @author Rossen Stoyanchev
2727
* @since 4.0
@@ -39,12 +39,12 @@ public interface HandlerMethodArgumentResolver {
3939

4040
/**
4141
* Resolves a method parameter into an argument value from a given message.
42-
* @param parameter the method parameter to resolve. This parameter must
43-
* have previously been passed to
42+
* @param parameter the method parameter to resolve.
43+
* This parameter must have previously been passed to
4444
* {@link #supportsParameter(org.springframework.core.MethodParameter)}
45-
* and it must have returned {@code true}
45+
* which must have returned {@code true}.
4646
* @param message the currently processed message
47-
* @return the resolved argument value, or {@code null}.
47+
* @return the resolved argument value, or {@code null}
4848
* @throws Exception in case of errors with the preparation of argument values
4949
*/
5050
Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception;

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

Lines changed: 5 additions & 8 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-2015 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.
@@ -68,7 +68,6 @@ public SimpleBrokerMessageHandler(SubscribableChannel clientInboundChannel, Mess
6868

6969
/**
7070
* Configure a custom SubscriptionRegistry to use for storing subscriptions.
71-
*
7271
* <p><strong>Note</strong> that when a custom PathMatcher is configured via
7372
* {@link #setPathMatcher}, if the custom registry is not an instance of
7473
* {@link DefaultSubscriptionRegistry}, the provided PathMatcher is not used
@@ -102,17 +101,16 @@ public void setPathMatcher(PathMatcher pathMatcher) {
102101
}
103102

104103
/**
105-
* Configure a {@link MessageHeaderInitializer} to apply to the headers of all
106-
* messages sent to the client outbound channel.
107-
*
104+
* Configure a {@link MessageHeaderInitializer} to apply to the headers
105+
* of all messages sent to the client outbound channel.
108106
* <p>By default this property is not set.
109107
*/
110108
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) {
111109
this.headerInitializer = headerInitializer;
112110
}
113111

114112
/**
115-
* @return the configured header initializer.
113+
* Return the configured header initializer.
116114
*/
117115
public MessageHeaderInitializer getHeaderInitializer() {
118116
return this.headerInitializer;
@@ -131,7 +129,6 @@ public void stopInternal() {
131129

132130
@Override
133131
protected void handleMessageInternal(Message<?> message) {
134-
135132
MessageHeaders headers = message.getHeaders();
136133
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers);
137134
String destination = SimpMessageHeaderAccessor.getDestination(headers);
@@ -197,7 +194,7 @@ private void initHeaders(SimpMessageHeaderAccessor accessor) {
197194

198195
protected void sendMessageToSubscribers(String destination, Message<?> message) {
199196
MultiValueMap<String,String> subscriptions = this.subscriptionRegistry.findSubscriptions(message);
200-
if ((subscriptions.size() > 0) && logger.isDebugEnabled()) {
197+
if (!subscriptions.isEmpty() && logger.isDebugEnabled()) {
201198
logger.debug("Broadcasting to " + subscriptions.size() + " sessions.");
202199
}
203200
for (String sessionId : subscriptions.keySet()) {

spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public Jackson2ObjectMapperBuilder deserializersByType(Map<Class<?>, JsonDeseria
232232
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class)
233233
*/
234234
public Jackson2ObjectMapperBuilder mixIn(Class<?> target, Class<?> mixinSource) {
235-
if (mixIns != null) {
235+
if (mixinSource != null) {
236236
this.mixIns.put(target, mixinSource);
237237
}
238238
return this;

0 commit comments

Comments
 (0)