Skip to content

Commit d04567b

Browse files
committed
Polishing
1 parent f2e1e1b commit d04567b

File tree

4 files changed

+26
-29
lines changed

4 files changed

+26
-29
lines changed

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

+4-7
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-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.
@@ -50,13 +50,10 @@ public abstract class Conventions {
5050
* when searching for the 'primary' interface of a proxy.
5151
*/
5252
private static final Set<Class<?>> IGNORED_INTERFACES;
53+
5354
static {
54-
IGNORED_INTERFACES = Collections.unmodifiableSet(
55-
new HashSet<Class<?>>(Arrays.<Class<?>> asList(
56-
Serializable.class,
57-
Externalizable.class,
58-
Cloneable.class,
59-
Comparable.class)));
55+
IGNORED_INTERFACES = Collections.unmodifiableSet(new HashSet<Class<?>>(Arrays.<Class<?>>asList(
56+
Serializable.class, Externalizable.class, Cloneable.class, Comparable.class)));
6057
}
6158

6259

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

+4-6
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.
@@ -54,8 +54,8 @@ public class InstanceFilter<T> {
5454
public InstanceFilter(Collection<? extends T> includes,
5555
Collection<? extends T> excludes, boolean matchIfEmpty) {
5656

57-
this.includes = includes != null ? includes : Collections.<T>emptyList();
58-
this.excludes = excludes != null ? excludes : Collections.<T>emptyList();
57+
this.includes = (includes != null ? includes : Collections.<T>emptyList());
58+
this.excludes = (excludes != null ? excludes : Collections.<T>emptyList());
5959
this.matchIfEmpty = matchIfEmpty;
6060
}
6161

@@ -64,7 +64,7 @@ public InstanceFilter(Collection<? extends T> includes,
6464
* Determine if the specified {code instance} matches this filter.
6565
*/
6666
public boolean match(T instance) {
67-
Assert.notNull(instance, "The instance to match is mandatory");
67+
Assert.notNull(instance, "Instance to match must not be null");
6868

6969
boolean includesSet = !this.includes.isEmpty();
7070
boolean excludesSet = !this.excludes.isEmpty();
@@ -74,11 +74,9 @@ public boolean match(T instance) {
7474

7575
boolean matchIncludes = match(instance, this.includes);
7676
boolean matchExcludes = match(instance, this.excludes);
77-
7877
if (!includesSet) {
7978
return !matchExcludes;
8079
}
81-
8280
if (!excludesSet) {
8381
return matchIncludes;
8482
}

spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractBrokerRegistration.java

+4-3
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-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.
@@ -50,8 +50,8 @@ public AbstractBrokerRegistration(SubscribableChannel clientInboundChannel,
5050
this.clientInboundChannel = clientInboundChannel;
5151
this.clientOutboundChannel = clientOutboundChannel;
5252

53-
this.destinationPrefixes = (destinationPrefixes != null)
54-
? Arrays.<String>asList(destinationPrefixes) : Collections.<String>emptyList();
53+
this.destinationPrefixes = (destinationPrefixes != null ?
54+
Arrays.asList(destinationPrefixes) : Collections.<String>emptyList());
5555
}
5656

5757

@@ -67,6 +67,7 @@ protected Collection<String> getDestinationPrefixes() {
6767
return this.destinationPrefixes;
6868
}
6969

70+
7071
protected abstract AbstractBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel);
7172

7273
}

spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java

+14-13
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.
@@ -43,8 +43,6 @@
4343
*/
4444
public abstract class AbstractWebSocketClient implements WebSocketClient {
4545

46-
protected final Log logger = LogFactory.getLog(getClass());
47-
4846
private static final Set<String> specialHeaders = new HashSet<String>();
4947

5048
static {
@@ -60,11 +58,14 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
6058
}
6159

6260

61+
protected final Log logger = LogFactory.getLog(getClass());
62+
63+
6364
@Override
6465
public ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
6566
String uriTemplate, Object... uriVars) {
6667

67-
Assert.notNull(uriTemplate, "uriTemplate must not be null");
68+
Assert.notNull(uriTemplate, "'uriTemplate' must not be null");
6869
URI uri = UriComponentsBuilder.fromUriString(uriTemplate).buildAndExpand(uriVars).encode().toUri();
6970
return doHandshake(webSocketHandler, null, uri);
7071
}
@@ -73,7 +74,7 @@ public ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocket
7374
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
7475
WebSocketHttpHeaders headers, URI uri) {
7576

76-
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
77+
Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
7778
assertUri(uri);
7879

7980
if (logger.isDebugEnabled()) {
@@ -89,25 +90,26 @@ public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler web
8990
}
9091
}
9192

92-
List<String> subProtocols = ((headers != null) && (headers.getSecWebSocketProtocol() != null)) ?
93-
headers.getSecWebSocketProtocol() : Collections.<String>emptyList();
93+
List<String> subProtocols = (headers != null && headers.getSecWebSocketProtocol() != null ?
94+
headers.getSecWebSocketProtocol() : Collections.<String>emptyList());
9495

95-
List<WebSocketExtension> extensions = ((headers != null) && (headers.getSecWebSocketExtensions() != null)) ?
96-
headers.getSecWebSocketExtensions() : Collections.<WebSocketExtension>emptyList();
96+
List<WebSocketExtension> extensions = (headers != null && headers.getSecWebSocketExtensions() != null ?
97+
headers.getSecWebSocketExtensions() : Collections.<WebSocketExtension>emptyList());
9798

9899
return doHandshakeInternal(webSocketHandler, headersToUse, uri, subProtocols, extensions,
99100
Collections.<String, Object>emptyMap());
100101
}
101102

102103
protected void assertUri(URI uri) {
103-
Assert.notNull(uri, "uri must not be null");
104+
Assert.notNull(uri, "URI must not be null");
104105
String scheme = uri.getScheme();
105-
Assert.isTrue(scheme != null && ("ws".equals(scheme) || "wss".equals(scheme)), "Invalid scheme: " + scheme);
106+
if (!"ws".equals(scheme) && !"wss".equals(scheme)) {
107+
throw new IllegalArgumentException("Invalid scheme: " + scheme);
108+
}
106109
}
107110

108111
/**
109112
* Perform the actual handshake to establish a connection to the server.
110-
*
111113
* @param webSocketHandler the client-side handler for WebSocket messages
112114
* @param headers HTTP headers to use for the handshake, with unwanted (forbidden)
113115
* headers filtered out, never {@code null}
@@ -116,7 +118,6 @@ protected void assertUri(URI uri) {
116118
* @param extensions requested WebSocket extensions, or an empty list
117119
* @param attributes attributes to associate with the WebSocketSession, i.e. via
118120
* {@link WebSocketSession#getAttributes()}; currently always an empty map.
119-
*
120121
* @return the established WebSocket session wrapped in a ListenableFuture.
121122
*/
122123
protected abstract ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler,

0 commit comments

Comments
 (0)