Explicit type can be replaced by <>

Issue: SPR-13188
This commit is contained in:
Stephane Nicoll
2016-07-05 17:00:26 +02:00
parent 3096888c7d
commit 00d2606b00
1044 changed files with 3972 additions and 3893 deletions

View File

@@ -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.
@@ -71,7 +71,7 @@ public class WebSocketExtension {
Assert.hasLength(name, "extension name must not be empty");
this.name = name;
if (!CollectionUtils.isEmpty(parameters)) {
Map<String, String> m = new LinkedCaseInsensitiveMap<String>(parameters.size(), Locale.ENGLISH);
Map<String, String> m = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
m.putAll(parameters);
this.parameters = Collections.unmodifiableMap(m);
}
@@ -106,7 +106,7 @@ public class WebSocketExtension {
return Collections.emptyList();
}
else {
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>();
List<WebSocketExtension> result = new ArrayList<>();
for (String token : extensions.split(",")) {
result.add(parseExtension(token));
}
@@ -121,7 +121,7 @@ public class WebSocketExtension {
Map<String, String> parameters = null;
if (parts.length > 1) {
parameters = new LinkedHashMap<String, String>(parts.length - 1);
parameters = new LinkedHashMap<>(parts.length - 1);
for (int i = 1; i < parts.length; i++) {
String parameter = parts[i];
int eqIndex = parameter.indexOf('=');

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -108,7 +108,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
return Collections.emptyList();
}
else {
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>(values.size());
List<WebSocketExtension> result = new ArrayList<>(values.size());
for (String value : values) {
result.addAll(WebSocketExtension.parseExtensions(value));
}
@@ -121,7 +121,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
* @param extensions the values for the header
*/
public void setSecWebSocketExtensions(List<WebSocketExtension> extensions) {
List<String> result = new ArrayList<String>(extensions.size());
List<String> result = new ArrayList<>(extensions.size());
for (WebSocketExtension extension : extensions) {
result.add(extension.toString());
}

View File

@@ -45,7 +45,7 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
private T nativeSession;
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
/**

View File

@@ -175,7 +175,7 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
this.acceptedProtocol = session.getUpgradeResponse().getAcceptedSubProtocol();
List<ExtensionConfig> source = getNativeSession().getUpgradeResponse().getExtensions();
this.extensions = new ArrayList<WebSocketExtension>(source.size());
this.extensions = new ArrayList<>(source.size());
for (ExtensionConfig ec : source) {
this.extensions.add(new WebSocketExtension(ec.getName(), ec.getParameters()));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -41,7 +41,7 @@ public class StandardToWebSocketExtensionAdapter extends WebSocketExtension {
private static Map<String, String> initParameters(Extension extension) {
List<Extension.Parameter> parameters = extension.getParameters();
Map<String, String> result = new LinkedCaseInsensitiveMap<String>(parameters.size(), Locale.ENGLISH);
Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
for (Extension.Parameter parameter : parameters) {
result.put(parameter.getName(), parameter.getValue());
}

View File

@@ -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.
@@ -182,7 +182,7 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
this.acceptedProtocol = session.getNegotiatedSubprotocol();
List<Extension> source = getNativeSession().getNegotiatedExtensions();
this.extensions = new ArrayList<WebSocketExtension>(source.size());
this.extensions = new ArrayList<>(source.size());
for (Extension ext : source) {
this.extensions.add(new StandardToWebSocketExtensionAdapter(ext));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -33,7 +33,7 @@ public class WebSocketToStandardExtensionAdapter implements Extension {
private final String name;
private final List<Parameter> parameters = new ArrayList<Parameter>();
private final List<Parameter> parameters = new ArrayList<>();
public WebSocketToStandardExtensionAdapter(final WebSocketExtension extension) {

View File

@@ -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.
@@ -45,7 +45,7 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
protected final Log logger = LogFactory.getLog(getClass());
private static final Set<String> specialHeaders = new HashSet<String>();
private static final Set<String> specialHeaders = new HashSet<>();
static {
specialHeaders.add("cache-control");

View File

@@ -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.
@@ -182,7 +182,7 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
return this.taskExecutor.submitListenable(connectTask);
}
else {
ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<WebSocketSession>(connectTask);
ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<>(connectTask);
task.run();
return task;
}

View File

@@ -60,7 +60,7 @@ public class AnnotatedEndpointConnectionManager extends ConnectionManagerSupport
public AnnotatedEndpointConnectionManager(Class<?> endpointClass, String uriTemplate, Object... uriVariables) {
super(uriTemplate, uriVariables);
this.endpointProvider = new BeanCreatingHandlerProvider<Object>(endpointClass);
this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass);
this.endpoint = null;
}

View File

@@ -71,7 +71,7 @@ public class EndpointConnectionManager extends ConnectionManagerSupport implemen
public EndpointConnectionManager(Class<? extends Endpoint> endpointClass, String uriTemplate, Object... uriVars) {
super(uriTemplate, uriVars);
Assert.notNull(endpointClass, "endpointClass must not be null");
this.endpointProvider = new BeanCreatingHandlerProvider<Endpoint>(endpointClass);
this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass);
this.endpoint = null;
}

View File

@@ -59,7 +59,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient {
private final WebSocketContainer webSocketContainer;
private final Map<String,Object> userProperties = new HashMap<String, Object>();
private final Map<String,Object> userProperties = new HashMap<>();
private AsyncListenableTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
@@ -155,14 +155,14 @@ public class StandardWebSocketClient extends AbstractWebSocketClient {
return this.taskExecutor.submitListenable(connectTask);
}
else {
ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<WebSocketSession>(connectTask);
ListenableFutureTask<WebSocketSession> task = new ListenableFutureTask<>(connectTask);
task.run();
return task;
}
}
private static List<Extension> adaptExtensions(List<WebSocketExtension> extensions) {
List<Extension> result = new ArrayList<Extension>();
List<Extension> result = new ArrayList<>();
for (WebSocketExtension extension : extensions) {
result.add(new WebSocketToStandardExtensionAdapter(extension));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -87,7 +87,7 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser {
strategy = new WebSocketHandlerMappingStrategy(handshakeHandler, interceptors);
}
ManagedMap<String, Object> urlMap = new ManagedMap<String, Object>();
ManagedMap<String, Object> urlMap = new ManagedMap<>();
urlMap.setSource(source);
for (Element mappingElement : DomUtils.getChildElementsByTagName(element, "mapping")) {
strategy.addMapping(mappingElement, urlMap, context);

View File

@@ -202,7 +202,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
handlerMappingDef.getPropertyValues().add("urlPathHelper", new RuntimeBeanReference(pathHelper));
}
ManagedMap<String, Object> urlMap = new ManagedMap<String, Object>();
ManagedMap<String, Object> urlMap = new ManagedMap<>();
urlMap.setSource(source);
handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
@@ -244,7 +244,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
argValues.addIndexedArgumentValue(0, new RuntimeBeanReference(executorName));
}
RootBeanDefinition channelDef = new RootBeanDefinition(ExecutorSubscribableChannel.class, argValues, null);
ManagedList<? super Object> interceptors = new ManagedList<Object>();
ManagedList<? super Object> interceptors = new ManagedList<>();
if (element != null) {
Element interceptorsElement = DomUtils.getChildElementByTagName(element, "interceptors");
interceptors.addAll(WebSocketNamespaceUtils.parseBeanSubElements(interceptorsElement, context));
@@ -410,7 +410,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
if (brokerRelayElem.hasAttribute("virtual-host")) {
values.add("virtualHost", brokerRelayElem.getAttribute("virtual-host"));
}
ManagedMap<String, Object> map = new ManagedMap<String, Object>();
ManagedMap<String, Object> map = new ManagedMap<>();
map.setSource(source);
if (brokerRelayElem.hasAttribute("user-destination-broadcast")) {
String destination = brokerRelayElem.getAttribute("user-destination-broadcast");
@@ -453,7 +453,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
private RuntimeBeanReference registerMessageConverter(Element element, ParserContext context, Object source) {
Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters");
ManagedList<? super Object> converters = new ManagedList<Object>();
ManagedList<? super Object> converters = new ManagedList<>();
if (convertersElement != null) {
converters.setSource(source);
for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) {
@@ -556,7 +556,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
}
private ManagedList<Object> extractBeanSubElements(Element parentElement, ParserContext parserContext) {
ManagedList<Object> list = new ManagedList<Object>();
ManagedList<Object> list = new ManagedList<>();
list.setSource(parserContext.extractSource(parentElement));
for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) {
Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -171,7 +171,7 @@ class WebSocketNamespaceUtils {
}
public static ManagedList<? super Object> parseBeanSubElements(Element parentElement, ParserContext context) {
ManagedList<? super Object> beans = new ManagedList<Object>();
ManagedList<? super Object> beans = new ManagedList<>();
if (parentElement != null) {
beans.setSource(context.extractSource(parentElement));
for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -45,13 +45,13 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
private final TaskScheduler sockJsTaskScheduler;
private MultiValueMap<WebSocketHandler, String> handlerMap = new LinkedMultiValueMap<WebSocketHandler, String>();
private MultiValueMap<WebSocketHandler, String> handlerMap = new LinkedMultiValueMap<>();
private HandshakeHandler handshakeHandler;
private final List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
private final List<HandshakeInterceptor> interceptors = new ArrayList<>();
private final List<String> allowedOrigins = new ArrayList<String>();
private final List<String> allowedOrigins = new ArrayList<>();
private SockJsServiceRegistration sockJsServiceRegistration;
@@ -114,7 +114,7 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
}
protected HandshakeInterceptor[] getInterceptors() {
List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
List<HandshakeInterceptor> interceptors = new ArrayList<>();
interceptors.addAll(this.interceptors);
interceptors.add(new OriginHandshakeInterceptor(this.allowedOrigins));
return interceptors.toArray(new HandshakeInterceptor[interceptors.size()]);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -34,7 +34,7 @@ import org.springframework.util.CollectionUtils;
@Configuration
public class DelegatingWebSocketConfiguration extends WebSocketConfigurationSupport {
private final List<WebSocketConfigurer> configurers = new ArrayList<WebSocketConfigurer>();
private final List<WebSocketConfigurer> configurers = new ArrayList<>();
@Autowired(required = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -42,7 +42,7 @@ import org.springframework.util.CollectionUtils;
@Configuration
public class DelegatingWebSocketMessageBrokerConfiguration extends WebSocketMessageBrokerConfigurationSupport {
private final List<WebSocketMessageBrokerConfigurer> configurers = new ArrayList<WebSocketMessageBrokerConfigurer>();
private final List<WebSocketMessageBrokerConfigurer> configurers = new ArrayList<>();
@Autowired(required = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -47,7 +47,7 @@ public class ServletWebSocketHandlerRegistration
@Override
protected MultiValueMap<HttpRequestHandler, String> createMappings() {
return new LinkedMultiValueMap<HttpRequestHandler, String>();
return new LinkedMultiValueMap<>();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -42,7 +42,7 @@ import org.springframework.web.util.UrlPathHelper;
public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry {
private final List<ServletWebSocketHandlerRegistration> registrations =
new ArrayList<ServletWebSocketHandlerRegistration>();
new ArrayList<>();
private TaskScheduler sockJsTaskScheduler;
@@ -93,7 +93,7 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
* Return a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s.
*/
public AbstractHandlerMapping getHandlerMapping() {
Map<String, Object> urlMap = new LinkedHashMap<String, Object>();
Map<String, Object> urlMap = new LinkedHashMap<>();
for (ServletWebSocketHandlerRegistration registration : this.registrations) {
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
for (HttpRequestHandler httpHandler : mappings.keySet()) {

View File

@@ -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.
@@ -56,13 +56,13 @@ public class SockJsServiceRegistration {
private Boolean webSocketEnabled;
private final List<TransportHandler> transportHandlers = new ArrayList<TransportHandler>();
private final List<TransportHandler> transportHandlers = new ArrayList<>();
private final List<TransportHandler> transportHandlerOverrides = new ArrayList<TransportHandler>();
private final List<TransportHandler> transportHandlerOverrides = new ArrayList<>();
private final List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
private final List<HandshakeInterceptor> interceptors = new ArrayList<>();
private final List<String> allowedOrigins = new ArrayList<String>();
private final List<String> allowedOrigins = new ArrayList<>();
private Boolean suppressCors;

View File

@@ -58,7 +58,7 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
private final StompSubProtocolHandler stompHandler;
private final List<WebMvcStompWebSocketEndpointRegistration> registrations =
new ArrayList<WebMvcStompWebSocketEndpointRegistration>();
new ArrayList<>();
public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler,
@@ -148,7 +148,7 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
* in case of no registrations.
*/
public AbstractHandlerMapping getHandlerMapping() {
Map<String, Object> urlMap = new LinkedHashMap<String, Object>();
Map<String, Object> urlMap = new LinkedHashMap<>();
for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
for (HttpRequestHandler httpHandler : mappings.keySet()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -51,9 +51,9 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
private HandshakeHandler handshakeHandler;
private final List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
private final List<HandshakeInterceptor> interceptors = new ArrayList<>();
private final List<String> allowedOrigins = new ArrayList<String>();
private final List<String> allowedOrigins = new ArrayList<>();
private StompSockJsServiceRegistration registration;
@@ -111,14 +111,14 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
}
protected HandshakeInterceptor[] getInterceptors() {
List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
List<HandshakeInterceptor> interceptors = new ArrayList<>();
interceptors.addAll(this.interceptors);
interceptors.add(new OriginHandshakeInterceptor(this.allowedOrigins));
return interceptors.toArray(new HandshakeInterceptor[interceptors.size()]);
}
public final MultiValueMap<HttpRequestHandler, String> getMappings() {
MultiValueMap<HttpRequestHandler, String> mappings = new LinkedMultiValueMap<HttpRequestHandler, String>();
MultiValueMap<HttpRequestHandler, String> mappings = new LinkedMultiValueMap<>();
if (this.registration != null) {
SockJsService sockJsService = this.registration.getSockJsService();
for (String path : this.paths) {

View File

@@ -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.
@@ -37,7 +37,7 @@ public class WebSocketTransportRegistration {
private Integer sendBufferSizeLimit;
private final List<WebSocketHandlerDecoratorFactory> decoratorFactories =
new ArrayList<WebSocketHandlerDecoratorFactory>(2);
new ArrayList<>(2);
/**

View File

@@ -53,7 +53,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
private final int bufferSizeLimit;
private final Queue<WebSocketMessage<?>> buffer = new LinkedBlockingQueue<WebSocketMessage<?>>();
private final Queue<WebSocketMessage<?>> buffer = new LinkedBlockingQueue<>();
private final AtomicInteger bufferSize = new AtomicInteger();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -53,7 +53,7 @@ public class PerConnectionWebSocketHandler implements WebSocketHandler, BeanFact
private final BeanCreatingHandlerProvider<WebSocketHandler> provider;
private final Map<WebSocketSession, WebSocketHandler> handlers =
new ConcurrentHashMap<WebSocketSession, WebSocketHandler>();
new ConcurrentHashMap<>();
private final boolean supportsPartialMessages;
@@ -63,7 +63,7 @@ public class PerConnectionWebSocketHandler implements WebSocketHandler, BeanFact
}
public PerConnectionWebSocketHandler(Class<? extends WebSocketHandler> handlerType, boolean supportsPartialMessages) {
this.provider = new BeanCreatingHandlerProvider<WebSocketHandler>(handlerType);
this.provider = new BeanCreatingHandlerProvider<>(handlerType);
this.supportsPartialMessages = supportsPartialMessages;
}

View File

@@ -47,10 +47,10 @@ import org.springframework.util.Assert;
public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicationListener {
/* Primary lookup that holds all users and their sessions */
private final Map<String, LocalSimpUser> users = new ConcurrentHashMap<String, LocalSimpUser>();
private final Map<String, LocalSimpUser> users = new ConcurrentHashMap<>();
/* Secondary lookup across all sessions by id */
private final Map<String, LocalSimpSession> sessions = new ConcurrentHashMap<String, LocalSimpSession>();
private final Map<String, LocalSimpSession> sessions = new ConcurrentHashMap<>();
private final Object sessionLock = new Object();
@@ -138,11 +138,11 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public Set<SimpUser> getUsers() {
return new HashSet<SimpUser>(this.users.values());
return new HashSet<>(this.users.values());
}
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher) {
Set<SimpSubscription> result = new HashSet<SimpSubscription>();
Set<SimpSubscription> result = new HashSet<>();
for (LocalSimpSession session : this.sessions.values()) {
for (SimpSubscription subscription : session.subscriptions.values()) {
if (matcher.match(subscription)) {
@@ -165,7 +165,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
private final String name;
private final Map<String, SimpSession> userSessions =
new ConcurrentHashMap<String, SimpSession>(1);
new ConcurrentHashMap<>(1);
public LocalSimpUser(String userName) {
@@ -190,7 +190,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public Set<SimpSession> getSessions() {
return new HashSet<SimpSession>(this.userSessions.values());
return new HashSet<>(this.userSessions.values());
}
void addSession(SimpSession session) {
@@ -229,7 +229,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
private final LocalSimpUser user;
private final Map<String, SimpSubscription> subscriptions = new ConcurrentHashMap<String, SimpSubscription>(4);
private final Map<String, SimpSubscription> subscriptions = new ConcurrentHashMap<>(4);
public LocalSimpSession(String id, LocalSimpUser user) {
@@ -251,7 +251,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public Set<SimpSubscription> getSubscriptions() {
return new HashSet<SimpSubscription>(this.subscriptions.values());
return new HashSet<>(this.subscriptions.values());
}
void addSubscription(String id, String destination) {

View File

@@ -98,7 +98,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private final StompDecoder stompDecoder = new StompDecoder();
private final Map<String, BufferingStompDecoder> decoders = new ConcurrentHashMap<String, BufferingStompDecoder>();
private final Map<String, BufferingStompDecoder> decoders = new ConcurrentHashMap<>();
private MessageHeaderInitializer headerInitializer;

View File

@@ -84,13 +84,13 @@ public class SubProtocolWebSocketHandler
private final SubscribableChannel clientOutboundChannel;
private final Map<String, SubProtocolHandler> protocolHandlerLookup =
new TreeMap<String, SubProtocolHandler>(String.CASE_INSENSITIVE_ORDER);
new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private final Set<SubProtocolHandler> protocolHandlers = new LinkedHashSet<SubProtocolHandler>();
private final Set<SubProtocolHandler> protocolHandlers = new LinkedHashSet<>();
private SubProtocolHandler defaultProtocolHandler;
private final Map<String, WebSocketSessionHolder> sessions = new ConcurrentHashMap<String, WebSocketSessionHolder>();
private final Map<String, WebSocketSessionHolder> sessions = new ConcurrentHashMap<>();
private int sendTimeLimit = 10 * 1000;
@@ -134,7 +134,7 @@ public class SubProtocolWebSocketHandler
}
public List<SubProtocolHandler> getProtocolHandlers() {
return new ArrayList<SubProtocolHandler>(this.protocolHandlers);
return new ArrayList<>(this.protocolHandlers);
}
/**
@@ -188,7 +188,7 @@ public class SubProtocolWebSocketHandler
* Return all supported protocols.
*/
public List<String> getSubProtocols() {
return new ArrayList<String>(this.protocolHandlerLookup.keySet());
return new ArrayList<>(this.protocolHandlerLookup.keySet());
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -92,7 +92,7 @@ public class WebSocketAnnotationMethodMessageHandler extends SimpAnnotationMetho
}
public static List<MessagingAdviceBean> createFromList(List<ControllerAdviceBean> beans) {
List<MessagingAdviceBean> result = new ArrayList<MessagingAdviceBean>(beans.size());
List<MessagingAdviceBean> result = new ArrayList<>(beans.size());
for (ControllerAdviceBean bean : beans) {
result.add(new MessagingControllerAdviceBean(bean));
}

View File

@@ -301,7 +301,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
private volatile long lastWriteTime = -1;
private final List<ScheduledFuture<?>> inactivityTasks = new ArrayList<ScheduledFuture<?>>(2);
private final List<ScheduledFuture<?>> inactivityTasks = new ArrayList<>(2);
public WebSocketTcpConnectionHandlerAdapter(TcpConnectionHandler<byte[]> connectionHandler) {
Assert.notNull(connectionHandler, "TcpConnectionHandler must not be null");
@@ -378,7 +378,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
@Override
public ListenableFuture<Void> send(Message<byte[]> message) {
updateLastWriteTime();
SettableListenableFuture<Void> future = new SettableListenableFuture<Void>();
SettableListenableFuture<Void> future = new SettableListenableFuture<>();
try {
this.session.sendMessage(this.codec.encode(message, this.session.getClass()));
future.set(null);

View File

@@ -66,7 +66,7 @@ import org.springframework.web.socket.server.RequestUpgradeStrategy;
public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Lifecycle, ServletContextAware {
private static final ThreadLocal<WebSocketHandlerContainer> wsContainerHolder =
new NamedThreadLocal<WebSocketHandlerContainer>("WebSocket Handler Container");
new NamedThreadLocal<>("WebSocket Handler Container");
private final WebSocketServerFactory factory;
@@ -126,7 +126,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
}
private List<WebSocketExtension> getWebSocketExtensions() {
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>();
List<WebSocketExtension> result = new ArrayList<>();
for (String name : this.factory.getExtensionFactory().getExtensionNames()) {
result.add(new WebSocketExtension(name));
}
@@ -213,7 +213,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
this.extensionConfigs = null;
}
else {
this.extensionConfigs = new ArrayList<ExtensionConfig>();
this.extensionConfigs = new ArrayList<>();
for (WebSocketExtension e : extensions) {
this.extensionConfigs.add(new WebSocketToJettyExtensionConfigAdapter(e));
}

View File

@@ -91,7 +91,7 @@ public abstract class AbstractStandardUpgradeStrategy implements RequestUpgradeS
}
protected List<WebSocketExtension> getInstalledExtensions(WebSocketContainer container) {
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>();
List<WebSocketExtension> result = new ArrayList<>();
for (Extension ext : container.getInstalledExtensions()) {
result.add(new StandardToWebSocketExtensionAdapter(ext));
}
@@ -123,7 +123,7 @@ public abstract class AbstractStandardUpgradeStrategy implements RequestUpgradeS
StandardWebSocketSession session = new StandardWebSocketSession(headers, attrs, localAddr, remoteAddr, user);
StandardWebSocketHandlerAdapter endpoint = new StandardWebSocketHandlerAdapter(wsHandler, session);
List<Extension> extensions = new ArrayList<Extension>();
List<Extension> extensions = new ArrayList<>();
for (WebSocketExtension extension : selectedExtensions) {
extensions.add(new WebSocketToStandardExtensionAdapter(extension));
}

View File

@@ -118,7 +118,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
return super.getInstalledExtensions(container);
}
catch (UnsupportedOperationException ex) {
return new ArrayList<WebSocketExtension>(0);
return new ArrayList<>(0);
}
}

View File

@@ -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.
@@ -112,7 +112,7 @@ public class ServerEndpointExporter extends WebApplicationObjectSupport
* Actually register the endpoints. Called by {@link #afterSingletonsInstantiated()}.
*/
protected void registerEndpoints() {
Set<Class<?>> endpointClasses = new LinkedHashSet<Class<?>>();
Set<Class<?>> endpointClasses = new LinkedHashSet<>();
if (this.annotatedEndpointClasses != null) {
endpointClasses.addAll(this.annotatedEndpointClasses);
}

View File

@@ -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.
@@ -60,15 +60,15 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
private final Endpoint endpoint;
private List<Class<? extends Encoder>> encoders = new ArrayList<Class<? extends Encoder>>();
private List<Class<? extends Encoder>> encoders = new ArrayList<>();
private List<Class<? extends Decoder>> decoders = new ArrayList<Class<? extends Decoder>>();
private List<Class<? extends Decoder>> decoders = new ArrayList<>();
private List<String> protocols = new ArrayList<String>();
private List<String> protocols = new ArrayList<>();
private List<Extension> extensions = new ArrayList<Extension>();
private List<Extension> extensions = new ArrayList<>();
private final Map<String, Object> userProperties = new HashMap<String, Object>();
private final Map<String, Object> userProperties = new HashMap<>();
/**
@@ -81,7 +81,7 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
Assert.hasText(path, "path must not be empty");
Assert.notNull(endpointClass, "endpointClass must not be null");
this.path = path;
this.endpointProvider = new BeanCreatingHandlerProvider<Endpoint>(endpointClass);
this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass);
this.endpoint = null;
}

View File

@@ -55,7 +55,7 @@ public class SpringConfigurator extends Configurator {
private static final Log logger = LogFactory.getLog(SpringConfigurator.class);
private static final Map<String, Map<Class<?>, String>> cache =
new ConcurrentHashMap<String, Map<Class<?>, String>>();
new ConcurrentHashMap<>();
@SuppressWarnings("unchecked")
@@ -102,7 +102,7 @@ public class SpringConfigurator extends Configurator {
Map<Class<?>, String> beanNamesByType = cache.get(wacId);
if (beanNamesByType == null) {
beanNamesByType = new ConcurrentHashMap<Class<?>, String>();
beanNamesByType = new ConcurrentHashMap<>();
cache.put(wacId, beanNamesByType);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -97,7 +97,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
private final RequestUpgradeStrategy requestUpgradeStrategy;
private final List<String> supportedProtocols = new ArrayList<String>();
private final List<String> supportedProtocols = new ArrayList<>();
private volatile boolean running = false;
@@ -386,7 +386,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
protected List<WebSocketExtension> filterRequestedExtensions(ServerHttpRequest request,
List<WebSocketExtension> requestedExtensions, List<WebSocketExtension> supportedExtensions) {
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>(requestedExtensions.size());
List<WebSocketExtension> result = new ArrayList<>(requestedExtensions.size());
for (WebSocketExtension extension : requestedExtensions) {
if (supportedExtensions.contains(extension)) {
result.add(extension);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -44,7 +44,7 @@ public class OriginHandshakeInterceptor implements HandshakeInterceptor {
protected Log logger = LogFactory.getLog(getClass());
private final Set<String> allowedOrigins = new LinkedHashSet<String>();
private final Set<String> allowedOrigins = new LinkedHashSet<>();
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -64,7 +64,7 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl
private final HandshakeHandler handshakeHandler;
private final List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
private final List<HandshakeInterceptor> interceptors = new ArrayList<>();
private volatile boolean running = false;
@@ -159,7 +159,7 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl
if (logger.isDebugEnabled()) {
logger.debug(servletRequest.getMethod() + " " + servletRequest.getRequestURI());
}
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
if (!chain.applyBeforeHandshake(request, response, attributes)) {
return;
}

View File

@@ -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.
@@ -58,7 +58,7 @@ public abstract class AbstractClientSockJsSession implements WebSocketSession {
private final SettableListenableFuture<WebSocketSession> connectFuture;
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
private volatile State state = State.NEW;

View File

@@ -95,7 +95,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
@Override
public ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler handler) {
SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<WebSocketSession>();
SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<>();
XhrClientSockJsSession session = new XhrClientSockJsSession(request, handler, this, connectFuture);
request.addTimeoutTask(session.getTimeoutTask());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -66,7 +66,7 @@ class DefaultTransportRequest implements TransportRequest {
private TaskScheduler timeoutScheduler;
private final List<Runnable> timeoutTasks = new ArrayList<Runnable>();
private final List<Runnable> timeoutTasks = new ArrayList<>();
private DefaultTransportRequest fallbackRequest;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -150,8 +150,8 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
HttpStatus status = HttpStatus.valueOf(response.getStatus());
HttpHeaders responseHeaders = toHttpHeaders(response.getHeaders());
return (response.getContent() != null ?
new ResponseEntity<String>(response.getContentAsString(), responseHeaders, status) :
new ResponseEntity<String>(responseHeaders, status));
new ResponseEntity<>(response.getContentAsString(), responseHeaders, status) :
new ResponseEntity<>(responseHeaders, status));
}
private static void addHttpHeaders(Request request, HttpHeaders headers) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -153,11 +153,11 @@ public class RestTemplateXhrTransport extends AbstractXhrTransport {
@Override
public ResponseEntity<String> extractData(ClientHttpResponse response) throws IOException {
if (response.getBody() == null) {
return new ResponseEntity<String>(response.getHeaders(), response.getStatusCode());
return new ResponseEntity<>(response.getHeaders(), response.getStatusCode());
}
else {
String body = StreamUtils.copyToString(response.getBody(), SockJsFrame.CHARSET);
return new ResponseEntity<String>(body, response.getHeaders(), response.getStatusCode());
return new ResponseEntity<>(body, response.getHeaders(), response.getStatusCode());
}
}
};

View File

@@ -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.
@@ -66,7 +66,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
private static final Log logger = LogFactory.getLog(SockJsClient.class);
private static final Set<String> supportedProtocols = new HashSet<String>(4);
private static final Set<String> supportedProtocols = new HashSet<>(4);
static {
supportedProtocols.add("ws");
@@ -88,7 +88,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
private volatile boolean running = false;
private final Map<URI, ServerInfo> serverInfoCache = new ConcurrentHashMap<URI, ServerInfo>();
private final Map<URI, ServerInfo> serverInfoCache = new ConcurrentHashMap<>();
/**
@@ -101,7 +101,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
*/
public SockJsClient(List<Transport> transports) {
Assert.notEmpty(transports, "No transports provided");
this.transports = new ArrayList<Transport>(transports);
this.transports = new ArrayList<>(transports);
this.infoReceiver = initInfoReceiver(transports);
if (jackson2Present) {
this.messageCodec = new Jackson2SockJsMessageCodec();
@@ -248,7 +248,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
throw new IllegalArgumentException("Invalid scheme: '" + scheme + "'");
}
SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<WebSocketSession>();
SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<>();
try {
SockJsUrlInfo sockJsUrlInfo = new SockJsUrlInfo(url);
ServerInfo serverInfo = getServerInfo(sockJsUrlInfo, getHttpRequestHeaders(headers));
@@ -292,7 +292,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle {
}
private DefaultTransportRequest createRequest(SockJsUrlInfo urlInfo, HttpHeaders headers, ServerInfo serverInfo) {
List<DefaultTransportRequest> requests = new ArrayList<DefaultTransportRequest>(this.transports.size());
List<DefaultTransportRequest> requests = new ArrayList<>(this.transports.size());
for (Transport transport : this.transports) {
for (TransportType type : transport.getTransportTypes()) {
if (serverInfo.isWebSocketEnabled() || !TransportType.WEBSOCKET.equals(type)) {

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -264,7 +264,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport {
protected ResponseEntity<String> executeRequest(URI url, HttpString method, HttpHeaders headers, String body) {
CountDownLatch latch = new CountDownLatch(1);
List<ClientResponse> responses = new CopyOnWriteArrayList<ClientResponse>();
List<ClientResponse> responses = new CopyOnWriteArrayList<>();
try {
ClientConnection connection =
@@ -285,8 +285,8 @@ public class UndertowXhrTransport extends AbstractXhrTransport {
HttpHeaders responseHeaders = toHttpHeaders(response.getResponseHeaders());
String responseBody = response.getAttachment(RESPONSE_BODY);
return (responseBody != null ?
new ResponseEntity<String>(responseBody, responseHeaders, status) :
new ResponseEntity<String>(responseHeaders, status));
new ResponseEntity<>(responseBody, responseHeaders, status) :
new ResponseEntity<>(responseHeaders, status));
}
finally {
IoUtils.safeClose(connection);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -74,7 +74,7 @@ public class WebSocketTransport implements Transport, Lifecycle {
@Override
public ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler handler) {
final SettableListenableFuture<WebSocketSession> future = new SettableListenableFuture<WebSocketSession>();
final SettableListenableFuture<WebSocketSession> future = new SettableListenableFuture<>();
WebSocketClientSockJsSession session = new WebSocketClientSockJsSession(request, handler, future);
handler = new ClientSockJsWebSocketHandler(session);
request.addTimeoutTask(session.getTimeoutTask());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -98,7 +98,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
private boolean suppressCors = false;
protected final Set<String> allowedOrigins = new LinkedHashSet<String>();
protected final Set<String> allowedOrigins = new LinkedHashSet<>();
public AbstractSockJsService(TaskScheduler scheduler) {
@@ -514,7 +514,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
protected void sendMethodNotAllowed(ServerHttpResponse response, HttpMethod... httpMethods) {
logger.warn("Sending Method Not Allowed (405)");
response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED);
response.getHeaders().setAllow(new HashSet<HttpMethod>(Arrays.asList(httpMethods)));
response.getHeaders().setAllow(new HashSet<>(Arrays.asList(httpMethods)));
}

View File

@@ -66,13 +66,13 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
"com.fasterxml.jackson.databind.ObjectMapper", TransportHandlingSockJsService.class.getClassLoader());
private final Map<TransportType, TransportHandler> handlers = new HashMap<TransportType, TransportHandler>();
private final Map<TransportType, TransportHandler> handlers = new HashMap<>();
private SockJsMessageCodec messageCodec;
private final List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
private final List<HandshakeInterceptor> interceptors = new ArrayList<>();
private final Map<String, SockJsSession> sessions = new ConcurrentHashMap<String, SockJsSession>();
private final Map<String, SockJsSession> sessions = new ConcurrentHashMap<>();
private ScheduledFuture<?> sessionCleanupTask;
@@ -199,7 +199,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
HandshakeFailureException failure = null;
try {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
if (!chain.applyBeforeHandshake(request, response, attributes)) {
return;
}
@@ -266,7 +266,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
SockJsSession session = this.sessions.get(sessionId);
if (session == null) {
if (transportHandler instanceof SockJsSessionFactory) {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
if (!chain.applyBeforeHandshake(request, response, attributes)) {
return;
}
@@ -362,7 +362,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
this.sessionCleanupTask = getTaskScheduler().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
List<String> removedIds = new ArrayList<String>();
List<String> removedIds = new ArrayList<>();
for (SockJsSession session : sessions.values()) {
try {
if (session.getTimeSinceLastActive() > getDisconnectDelay()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -53,7 +53,7 @@ public enum TransportType {
private static final Map<String, TransportType> TRANSPORT_TYPES;
static {
Map<String, TransportType> transportTypes = new HashMap<String, TransportType>();
Map<String, TransportType> transportTypes = new HashMap<>();
for (TransportType type : values()) {
transportTypes.put(type.value, type);
}

View File

@@ -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.
@@ -79,7 +79,7 @@ public class DefaultSockJsService extends TransportHandlingSockJsService impleme
private static Set<TransportHandler> getDefaultTransportHandlers(Collection<TransportHandler> overrides) {
Set<TransportHandler> result = new LinkedHashSet<TransportHandler>(8);
Set<TransportHandler> result = new LinkedHashSet<>(8);
result.add(new XhrPollingTransportHandler());
result.add(new XhrReceivingTransportHandler());
result.add(new XhrStreamingTransportHandler());

View File

@@ -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.
@@ -69,7 +69,7 @@ public class SockJsWebSocketHandler extends TextWebSocketHandler implements SubP
webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler);
this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ?
new ArrayList<String>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : null);
new ArrayList<>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : null);
}
@Override

View File

@@ -84,7 +84,7 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
WebSocketHandler wsHandler, Map<String, Object> attributes) {
super(id, config, wsHandler, attributes);
this.messageCache = new LinkedBlockingQueue<String>(config.getHttpMessageCacheSize());
this.messageCache = new LinkedBlockingQueue<>(config.getHttpMessageCacheSize());
}

View File

@@ -81,7 +81,7 @@ public abstract class AbstractSockJsSession implements SockJsSession {
private static final Set<String> disconnectedClientExceptions;
static {
Set<String> set = new HashSet<String>(2);
Set<String> set = new HashSet<>(2);
set.add("ClientAbortException"); // Tomcat
set.add("EOFException"); // Tomcat
set.add("EofException"); // Jetty
@@ -98,7 +98,7 @@ public abstract class AbstractSockJsSession implements SockJsSession {
private final WebSocketHandler handler;
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
private volatile State state = State.NEW;
@@ -399,7 +399,7 @@ public abstract class AbstractSockJsSession implements SockJsSession {
}
public void delegateMessages(String... messages) throws SockJsMessageDeliveryException {
List<String> undelivered = new ArrayList<String>(Arrays.asList(messages));
List<String> undelivered = new ArrayList<>(Arrays.asList(messages));
for (String message : messages) {
try {
if (isClosed()) {

View File

@@ -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.
@@ -50,7 +50,7 @@ public class WebSocketServerSockJsSession extends AbstractSockJsSession implemen
private volatile boolean openFrameSent;
private final Queue<String> initSessionCache = new LinkedBlockingDeque<String>();
private final Queue<String> initSessionCache = new LinkedBlockingDeque<>();
private final Object initSessionLock = new Object();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -50,7 +50,7 @@ public abstract class AbstractWebSocketIntegrationTests {
protected Log logger = LogFactory.getLog(getClass());
private static Map<Class<?>, Class<?>> upgradeStrategyConfigTypes = new HashMap<Class<?>, Class<?>>();
private static Map<Class<?>, Class<?>> upgradeStrategyConfigTypes = new HashMap<>();
static {
upgradeStrategyConfigTypes.put(JettyWebSocketTestServer.class, JettyUpgradeStrategyConfig.class);

View File

@@ -198,7 +198,7 @@ public class MessageBrokerBeanDefinitionParserTests {
SimpleBrokerMessageHandler brokerMessageHandler = this.appContext.getBean(SimpleBrokerMessageHandler.class);
assertNotNull(brokerMessageHandler);
Collection<String> prefixes = brokerMessageHandler.getDestinationPrefixes();
assertEquals(Arrays.asList("/topic", "/queue"), new ArrayList<String>(prefixes));
assertEquals(Arrays.asList("/topic", "/queue"), new ArrayList<>(prefixes));
assertNotNull(brokerMessageHandler.getTaskScheduler());
assertArrayEquals(new long[] {15000, 15000}, brokerMessageHandler.getHeartbeatValue());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -39,7 +39,7 @@ public class BeanCreatingHandlerProviderTests {
public void getHandlerSimpleInstantiation() {
BeanCreatingHandlerProvider<SimpleEchoHandler> provider =
new BeanCreatingHandlerProvider<SimpleEchoHandler>(SimpleEchoHandler.class);
new BeanCreatingHandlerProvider<>(SimpleEchoHandler.class);
assertNotNull(provider.getHandler());
}
@@ -51,7 +51,7 @@ public class BeanCreatingHandlerProviderTests {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
BeanCreatingHandlerProvider<EchoHandler> provider =
new BeanCreatingHandlerProvider<EchoHandler>(EchoHandler.class);
new BeanCreatingHandlerProvider<>(EchoHandler.class);
provider.setBeanFactory(context.getBeanFactory());
assertNotNull(provider.getHandler());
@@ -61,7 +61,7 @@ public class BeanCreatingHandlerProviderTests {
public void getHandlerNoBeanFactory() {
BeanCreatingHandlerProvider<EchoHandler> provider =
new BeanCreatingHandlerProvider<EchoHandler>(EchoHandler.class);
new BeanCreatingHandlerProvider<>(EchoHandler.class);
provider.getHandler();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -42,7 +42,7 @@ public class TestWebSocketSession implements WebSocketSession {
private URI uri;
private Map<String, Object> attributes = new HashMap<String, Object>();
private Map<String, Object> attributes = new HashMap<>();
private Principal principal;
@@ -52,7 +52,7 @@ public class TestWebSocketSession implements WebSocketSession {
private String protocol;
private List<WebSocketExtension> extensions = new ArrayList<WebSocketExtension>();
private List<WebSocketExtension> extensions = new ArrayList<>();
private boolean open;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -44,7 +44,7 @@ public class WebSocketHttpHeadersTests {
@Test
public void parseWebSocketExtensions() {
List<String> extensions = new ArrayList<String>();
List<String> extensions = new ArrayList<>();
extensions.add("x-foo-extension, x-bar-extension");
extensions.add("x-test-extension");
this.headers.put(WebSocketHttpHeaders.SEC_WEBSOCKET_EXTENSIONS, extensions);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -468,7 +468,7 @@ public class StompSubProtocolHandlerTests {
private static class TestPublisher implements ApplicationEventPublisher {
private final List<ApplicationEvent> events = new ArrayList<ApplicationEvent>();
private final List<ApplicationEvent> events = new ArrayList<>();
@Override
public void publishEvent(ApplicationEvent event) {
@@ -477,7 +477,7 @@ public class StompSubProtocolHandlerTests {
@Override
public void publishEvent(Object event) {
publishEvent(new PayloadApplicationEvent<Object>(this, event));
publishEvent(new PayloadApplicationEvent<>(this, event));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -32,7 +32,7 @@ public class StompTextMessageBuilder {
private StompCommand command;
private final List<String> headerLines = new ArrayList<String>();
private final List<String> headerLines = new ArrayList<>();
private String body;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 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.
@@ -57,7 +57,7 @@ public class HandshakeInterceptorChainTests extends AbstractHttpRequestTests {
i3 = mock(HandshakeInterceptor.class);
interceptors = Arrays.asList(i1, i2, i3);
wsHandler = mock(WebSocketHandler.class);
attributes = new HashMap<String, Object>();
attributes = new HashMap<>();
}

View File

@@ -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.
@@ -40,7 +40,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes
@Test
public void defaultConstructor() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.setSession(new MockHttpSession(null, "123"));
@@ -58,7 +58,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes
@Test
public void constructorWithAttributeNames() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.setSession(new MockHttpSession(null, "123"));
@@ -76,7 +76,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes
@Test
public void doNotCopyHttpSessionId() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.setSession(new MockHttpSession(null, "123"));
@@ -93,7 +93,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes
@Test
public void doNotCopyAttributes() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.setSession(new MockHttpSession(null, "123"));
@@ -109,7 +109,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes
@Test
public void doNotCauseSessionCreation() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -47,7 +47,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void originValueMatch() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com");
List<String> allowed = Collections.singletonList("http://mydomain1.com");
@@ -58,7 +58,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void originValueNoMatch() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com");
List<String> allowed = Collections.singletonList("http://mydomain2.com");
@@ -69,7 +69,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void originListMatch() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
List<String> allowed = Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com");
@@ -80,7 +80,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void originListNoMatch() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain4.com");
List<String> allowed = Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com");
@@ -91,11 +91,11 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void originNoMatchWithNullHostileCollection() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain4.com");
OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
Set<String> allowedOrigins = new ConcurrentSkipListSet<String>();
Set<String> allowedOrigins = new ConcurrentSkipListSet<>();
allowedOrigins.add("http://mydomain1.com");
interceptor.setAllowedOrigins(allowedOrigins);
assertFalse(interceptor.beforeHandshake(request, response, wsHandler, attributes));
@@ -104,7 +104,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void originMatchAll() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com");
OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
@@ -115,7 +115,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void sameOriginMatchWithEmptyAllowedOrigins() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
this.servletRequest.setServerName("mydomain2.com");
@@ -126,7 +126,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void sameOriginMatchWithAllowedOrigins() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
this.servletRequest.setServerName("mydomain2.com");
@@ -137,7 +137,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
@Test
public void sameOriginNoMatch() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
Map<String, Object> attributes = new HashMap<>();
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain3.com");
this.servletRequest.setServerName("mydomain2.com");