Avoid unnecessary generics on emptyMap/Set/List
This commit is contained in:
@@ -43,8 +43,6 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
*/
|
||||
public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private static final Set<String> specialHeaders = new HashSet<>();
|
||||
|
||||
static {
|
||||
@@ -60,11 +58,14 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||
}
|
||||
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
||||
@Override
|
||||
public ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
|
||||
String uriTemplate, Object... uriVars) {
|
||||
|
||||
Assert.notNull(uriTemplate, "uriTemplate must not be null");
|
||||
Assert.notNull(uriTemplate, "'uriTemplate' must not be null");
|
||||
URI uri = UriComponentsBuilder.fromUriString(uriTemplate).buildAndExpand(uriVars).encode().toUri();
|
||||
return doHandshake(webSocketHandler, null, uri);
|
||||
}
|
||||
@@ -73,7 +74,7 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
|
||||
WebSocketHttpHeaders headers, URI uri) {
|
||||
|
||||
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
|
||||
Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
|
||||
assertUri(uri);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -89,25 +90,26 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> subProtocols = ((headers != null) && (headers.getSecWebSocketProtocol() != null)) ?
|
||||
headers.getSecWebSocketProtocol() : Collections.<String>emptyList();
|
||||
List<String> subProtocols = (headers != null && headers.getSecWebSocketProtocol() != null ?
|
||||
headers.getSecWebSocketProtocol() : Collections.emptyList());
|
||||
|
||||
List<WebSocketExtension> extensions = ((headers != null) && (headers.getSecWebSocketExtensions() != null)) ?
|
||||
headers.getSecWebSocketExtensions() : Collections.<WebSocketExtension>emptyList();
|
||||
List<WebSocketExtension> extensions = (headers != null && headers.getSecWebSocketExtensions() != null ?
|
||||
headers.getSecWebSocketExtensions() : Collections.emptyList());
|
||||
|
||||
return doHandshakeInternal(webSocketHandler, headersToUse, uri, subProtocols, extensions,
|
||||
Collections.<String, Object>emptyMap());
|
||||
Collections.emptyMap());
|
||||
}
|
||||
|
||||
protected void assertUri(URI uri) {
|
||||
Assert.notNull(uri, "uri must not be null");
|
||||
Assert.notNull(uri, "URI must not be null");
|
||||
String scheme = uri.getScheme();
|
||||
Assert.isTrue(scheme != null && ("ws".equals(scheme) || "wss".equals(scheme)), "Invalid scheme: " + scheme);
|
||||
if (!"ws".equals(scheme) && !"wss".equals(scheme)) {
|
||||
throw new IllegalArgumentException("Invalid scheme: " + scheme);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the actual handshake to establish a connection to the server.
|
||||
*
|
||||
* @param webSocketHandler the client-side handler for WebSocket messages
|
||||
* @param headers HTTP headers to use for the handshake, with unwanted (forbidden)
|
||||
* headers filtered out, never {@code null}
|
||||
@@ -116,7 +118,6 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
|
||||
* @param extensions requested WebSocket extensions, or an empty list
|
||||
* @param attributes attributes to associate with the WebSocketSession, i.e. via
|
||||
* {@link WebSocketSession#getAttributes()}; currently always an empty map.
|
||||
*
|
||||
* @return the established WebSocket session wrapped in a ListenableFuture.
|
||||
*/
|
||||
protected abstract ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler,
|
||||
|
||||
@@ -468,7 +468,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
|
||||
}
|
||||
|
||||
public List<Message<byte[]>> decode(WebSocketMessage<?> webSocketMessage) {
|
||||
List<Message<byte[]>> result = Collections.<Message<byte[]>>emptyList();
|
||||
List<Message<byte[]>> result = Collections.emptyList();
|
||||
ByteBuffer byteBuffer;
|
||||
if (webSocketMessage instanceof TextMessage) {
|
||||
byteBuffer = ByteBuffer.wrap(((TextMessage) webSocketMessage).asBytes());
|
||||
|
||||
@@ -66,7 +66,7 @@ public class UndertowRequestUpgradeStrategy extends AbstractStandardUpgradeStrat
|
||||
|
||||
StringBuffer requestUrl = servletRequest.getRequestURL();
|
||||
String path = servletRequest.getRequestURI(); // shouldn't matter
|
||||
Map<String, String> pathParams = Collections.<String, String>emptyMap();
|
||||
Map<String, String> pathParams = Collections.emptyMap();
|
||||
|
||||
ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint);
|
||||
endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol));
|
||||
|
||||
@@ -367,7 +367,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||
if (handlerToCheck instanceof SubProtocolCapable) {
|
||||
subProtocols = ((SubProtocolCapable) handlerToCheck).getSubProtocols();
|
||||
}
|
||||
return (subProtocols != null ? subProtocols : Collections.<String>emptyList());
|
||||
return (subProtocols != null ? subProtocols : Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ public class HandshakeInterceptorChain {
|
||||
|
||||
|
||||
public HandshakeInterceptorChain(List<HandshakeInterceptor> interceptors, WebSocketHandler wsHandler) {
|
||||
this.interceptors = (interceptors != null ? interceptors : Collections.<HandshakeInterceptor>emptyList());
|
||||
this.interceptors = (interceptors != null ? interceptors : Collections.emptyList());
|
||||
this.wsHandler = wsHandler;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user