diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index cf9ee614c66..414b71a2bd8 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -555,7 +555,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker public Collection get(Class operationClass) { Collection result = this.contexts.get(operationClass); - return (result != null ? result : Collections.emptyList()); + return (result != null ? result : Collections.emptyList()); } public boolean isSynchronized() { diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java index 771df301795..a613c0b7821 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java @@ -134,7 +134,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public List getTriggerTaskList() { return (this.triggerTasks != null? Collections.unmodifiableList(this.triggerTasks) : - Collections.emptyList()); + Collections.emptyList()); } /** @@ -165,7 +165,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public List getCronTaskList() { return (this.cronTasks != null ? Collections.unmodifiableList(this.cronTasks) : - Collections.emptyList()); + Collections.emptyList()); } /** @@ -196,7 +196,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public List getFixedRateTaskList() { return (this.fixedRateTasks != null ? Collections.unmodifiableList(this.fixedRateTasks) : - Collections.emptyList()); + Collections.emptyList()); } /** @@ -227,7 +227,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public List getFixedDelayTaskList() { return (this.fixedDelayTasks != null ? Collections.unmodifiableList(this.fixedDelayTasks) : - Collections.emptyList()); + Collections.emptyList()); } diff --git a/spring-core/src/main/java/org/springframework/core/Conventions.java b/spring-core/src/main/java/org/springframework/core/Conventions.java index 867ff4fc5da..f016df5d10a 100644 --- a/spring-core/src/main/java/org/springframework/core/Conventions.java +++ b/spring-core/src/main/java/org/springframework/core/Conventions.java @@ -50,13 +50,10 @@ public abstract class Conventions { * when searching for the 'primary' interface of a proxy. */ private static final Set> IGNORED_INTERFACES; + static { - IGNORED_INTERFACES = Collections.unmodifiableSet( - new HashSet<>(Arrays.>asList( - Serializable.class, - Externalizable.class, - Cloneable.class, - Comparable.class))); + IGNORED_INTERFACES = Collections.unmodifiableSet(new HashSet<>( + Arrays.asList(Serializable.class, Externalizable.class, Cloneable.class, Comparable.class))); } diff --git a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java index b35a4cb53f1..9b3fa2668c2 100644 --- a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java @@ -101,7 +101,7 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySourceemptyList() : null); + return (this.source.has(name) ? Collections.emptyList() : null); } return Collections.unmodifiableList(stringArgValues); } @@ -114,7 +114,7 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySourceemptyList() : + return (stringArgValues.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(stringArgValues)); } diff --git a/spring-core/src/main/java/org/springframework/util/InstanceFilter.java b/spring-core/src/main/java/org/springframework/util/InstanceFilter.java index 6aa84612389..f97eb978470 100644 --- a/spring-core/src/main/java/org/springframework/util/InstanceFilter.java +++ b/spring-core/src/main/java/org/springframework/util/InstanceFilter.java @@ -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. @@ -54,8 +54,8 @@ public class InstanceFilter { public InstanceFilter(Collection includes, Collection excludes, boolean matchIfEmpty) { - this.includes = includes != null ? includes : Collections.emptyList(); - this.excludes = excludes != null ? excludes : Collections.emptyList(); + this.includes = (includes != null ? includes : Collections.emptyList()); + this.excludes = (excludes != null ? excludes : Collections.emptyList()); this.matchIfEmpty = matchIfEmpty; } @@ -64,7 +64,7 @@ public class InstanceFilter { * Determine if the specified {code instance} matches this filter. */ public boolean match(T instance) { - Assert.notNull(instance, "The instance to match is mandatory"); + Assert.notNull(instance, "Instance to match must not be null"); boolean includesSet = !this.includes.isEmpty(); boolean excludesSet = !this.excludes.isEmpty(); @@ -74,11 +74,9 @@ public class InstanceFilter { boolean matchIncludes = match(instance, this.includes); boolean matchExcludes = match(instance, this.excludes); - if (!includesSet) { return !matchExcludes; } - if (!excludesSet) { return matchIncludes; } diff --git a/spring-core/src/main/java/org/springframework/util/MimeType.java b/spring-core/src/main/java/org/springframework/util/MimeType.java index d3eeae3486f..2512ecd69d2 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeType.java +++ b/spring-core/src/main/java/org/springframework/util/MimeType.java @@ -120,7 +120,7 @@ public class MimeType implements Comparable, Serializable { * @throws IllegalArgumentException if any of the parameters contains illegal characters */ public MimeType(String type, String subtype) { - this(type, subtype, Collections.emptyMap()); + this(type, subtype, Collections.emptyMap()); } /** diff --git a/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java b/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java index 5f61b36f241..3ea95db9bb1 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java +++ b/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java @@ -87,7 +87,7 @@ public class SimpleNamespaceContext implements NamespaceContext { } else { Set prefixes = this.namespaceUriToPrefixes.get(namespaceUri); - return (prefixes != null ? Collections.unmodifiableSet(prefixes) : Collections.emptySet()); + return (prefixes != null ? Collections.unmodifiableSet(prefixes) : Collections.emptySet()); } } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java b/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java index 611e848b2d5..7b45e34ba53 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java @@ -183,7 +183,7 @@ public class ExpressionState { public void enterScope() { ensureVariableScopesInitialized(); - this.variableScopes.push(new VariableScope(Collections.emptyMap())); + this.variableScopes.push(new VariableScope(Collections.emptyMap())); this.scopeRootObjects.push(getActiveContextObject()); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java index 69c4f7e5287..3bf7bdbcf12 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java @@ -73,7 +73,7 @@ public class DestinationPatternsMessageCondition extends AbstractMessageConditio private static List asList(String... patterns) { - return (patterns != null ? Arrays.asList(patterns) : Collections.emptyList()); + return (patterns != null ? Arrays.asList(patterns) : Collections.emptyList()); } private static Set prependLeadingSlash(Collection patterns, PathMatcher pathMatcher) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java index 1d914cb0079..939a4c0c776 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java @@ -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. @@ -84,7 +84,7 @@ public abstract class AbstractBrokerMessageHandler public AbstractBrokerMessageHandler(SubscribableChannel inboundChannel, MessageChannel outboundChannel, SubscribableChannel brokerChannel) { - this(inboundChannel, outboundChannel, brokerChannel, Collections.emptyList()); + this(inboundChannel, outboundChannel, brokerChannel, Collections.emptyList()); } /** @@ -105,7 +105,7 @@ public abstract class AbstractBrokerMessageHandler this.clientOutboundChannel = outboundChannel; this.brokerChannel = brokerChannel; - destinationPrefixes = (destinationPrefixes != null) ? destinationPrefixes : Collections.emptyList(); + destinationPrefixes = (destinationPrefixes != null) ? destinationPrefixes : Collections.emptyList(); this.destinationPrefixes = Collections.unmodifiableCollection(destinationPrefixes); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractBrokerRegistration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractBrokerRegistration.java index 93a25239cb3..f6f6de3db76 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractBrokerRegistration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractBrokerRegistration.java @@ -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. @@ -50,8 +50,8 @@ public abstract class AbstractBrokerRegistration { this.clientInboundChannel = clientInboundChannel; this.clientOutboundChannel = clientOutboundChannel; - this.destinationPrefixes = (destinationPrefixes != null) - ? Arrays.asList(destinationPrefixes) : Collections.emptyList(); + this.destinationPrefixes = (destinationPrefixes != null ? + Arrays.asList(destinationPrefixes) : Collections.emptyList()); } @@ -67,6 +67,7 @@ public abstract class AbstractBrokerRegistration { return this.destinationPrefixes; } + protected abstract AbstractBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java index 74a5ce65382..78ce589c553 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaderAccessor.java @@ -182,7 +182,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor { Map> getNativeHeaders() { @SuppressWarnings("unchecked") Map> map = (Map>) getHeader(NATIVE_HEADERS); - return (map != null ? map : Collections.>emptyMap()); + return (map != null ? map : Collections.emptyMap()); } public StompCommand updateStompCommandAsClientMessage() { @@ -242,7 +242,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor { public Set getAcceptVersion() { String rawValue = getFirstNativeHeader(STOMP_ACCEPT_VERSION_HEADER); - return (rawValue != null ? StringUtils.commaDelimitedListToSet(rawValue) : Collections.emptySet()); + return (rawValue != null ? StringUtils.commaDelimitedListToSet(rawValue) : Collections.emptySet()); } public void setHost(String host) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java index 6c91b57b5a6..291fc585e7e 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java @@ -188,7 +188,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver { } } else { - sessionIds = Collections.emptySet(); + sessionIds = Collections.emptySet(); } } if (!this.keepLeadingSlash) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java index ca0c164eed4..7ff5c88c249 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java @@ -94,7 +94,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { */ public Map> toNativeHeaderMap() { Map> map = getNativeHeaders(); - return (map != null ? new LinkedMultiValueMap<>(map) : Collections.>emptyMap()); + return (map != null ? new LinkedMultiValueMap<>(map) : Collections.emptyMap()); } @Override diff --git a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java index b137b5b7713..4ff624314e5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java @@ -299,8 +299,7 @@ public class Reactor2TcpClient

implements TcpOperations

{ @Override public ReactorConfiguration read() { - return new ReactorConfiguration( - Collections.emptyList(), "sync", new Properties()); + return new ReactorConfiguration(Collections.emptyList(), "sync", new Properties()); } } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java b/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java index 9d45cb72479..e35ade005de 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java @@ -425,13 +425,13 @@ public class MockServletContext implements ServletContext { @Override @Deprecated public Enumeration getServlets() { - return Collections.enumeration(Collections.emptySet()); + return Collections.enumeration(Collections.emptySet()); } @Override @Deprecated public Enumeration getServletNames() { - return Collections.enumeration(Collections.emptySet()); + return Collections.enumeration(Collections.emptySet()); } @Override diff --git a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java index 7531b93082a..0ac2553383e 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java @@ -132,7 +132,7 @@ public abstract class TestPropertySourceUtils { if (logger.isTraceEnabled()) { logger.trace(String.format("Processing inlined properties for TestPropertySource attributes %s", attrs)); } - properties.addAll(0, Arrays.asList(attrs.getProperties())); + properties.addAll(0, Arrays.asList(attrs.getProperties())); if (!attrs.isInheritProperties()) { break; } diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index 07fec35da52..5d0567d5f85 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -269,7 +269,7 @@ public class MediaType extends MimeType implements Serializable { * @throws IllegalArgumentException if any of the parameters contain illegal characters */ public MediaType(String type, String subtype) { - super(type, subtype, Collections.emptyMap()); + super(type, subtype, Collections.emptyMap()); } /** @@ -463,7 +463,7 @@ public class MediaType extends MimeType implements Serializable { */ public static List parseMediaTypes(List mediaTypes) { if (CollectionUtils.isEmpty(mediaTypes)) { - return Collections.emptyList(); + return Collections.emptyList(); } else if (mediaTypes.size() == 1) { return parseMediaTypes(mediaTypes.get(0)); diff --git a/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequestFactory.java b/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequestFactory.java index 1ca68c5249a..b12e706207f 100644 --- a/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequestFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/InterceptingAsyncClientHttpRequestFactory.java @@ -47,7 +47,7 @@ public class InterceptingAsyncClientHttpRequestFactory implements AsyncClientHtt List interceptors) { this.delegate = delegate; - this.interceptors = (interceptors != null ? interceptors : Collections.emptyList()); + this.interceptors = (interceptors != null ? interceptors : Collections.emptyList()); } diff --git a/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequestFactory.java b/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequestFactory.java index aadab069511..7af54330c78 100644 --- a/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequestFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/InterceptingClientHttpRequestFactory.java @@ -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 @@ public class InterceptingClientHttpRequestFactory extends AbstractClientHttpRequ List interceptors) { super(requestFactory); - this.interceptors = (interceptors != null ? interceptors : Collections.emptyList()); + this.interceptors = (interceptors != null ? interceptors : Collections.emptyList()); } @Override diff --git a/spring-web/src/main/java/org/springframework/web/accept/HeaderContentNegotiationStrategy.java b/spring-web/src/main/java/org/springframework/web/accept/HeaderContentNegotiationStrategy.java index 89dd23a2118..c758ea4bbed 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/HeaderContentNegotiationStrategy.java +++ b/spring-web/src/main/java/org/springframework/web/accept/HeaderContentNegotiationStrategy.java @@ -45,7 +45,7 @@ public class HeaderContentNegotiationStrategy implements ContentNegotiationStrat String[] headerValueArray = request.getHeaderValues(HttpHeaders.ACCEPT); if (headerValueArray == null) { - return Collections.emptyList(); + return Collections.emptyList(); } List headerValues = Arrays.asList(headerValueArray); diff --git a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java index c92c1bc9acb..4d9d84117a2 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java +++ b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java @@ -90,7 +90,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten @Override public List resolveFileExtensions(MediaType mediaType) { List fileExtensions = this.fileExtensions.get(mediaType); - return (fileExtensions != null) ? fileExtensions : Collections.emptyList(); + return (fileExtensions != null) ? fileExtensions : Collections.emptyList(); } @Override diff --git a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java index d95316f5cab..940e27f650f 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java @@ -213,7 +213,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { @Override public Enumeration getHeaders(String name) { List value = this.headers.get(name); - return (Collections.enumeration(value != null ? value : Collections.emptySet())); + return (Collections.enumeration(value != null ? value : Collections.emptySet())); } @Override diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index 7edcc4a0311..7831703ce86 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -590,7 +590,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap private void addMappingName(String name, HandlerMethod handlerMethod) { List oldList = this.nameLookup.get(name); if (oldList == null) { - oldList = Collections.emptyList(); + oldList = Collections.emptyList(); } for (HandlerMethod current : oldList) { @@ -685,7 +685,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap Assert.notNull(handlerMethod); this.mapping = mapping; this.handlerMethod = handlerMethod; - this.directUrls = (directUrls != null ? directUrls : Collections.emptyList()); + this.directUrls = (directUrls != null ? directUrls : Collections.emptyList()); this.mappingName = mappingName; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletPostProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletPostProcessor.java index d6fef3b68c9..9fa7853e7f6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletPostProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletPostProcessor.java @@ -163,7 +163,7 @@ public class SimpleServletPostProcessor implements @Override public Enumeration getInitParameterNames() { - return Collections.enumeration(Collections.emptySet()); + return Collections.enumeration(Collections.emptySet()); } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java index 43d14fd453a..25f8046d067 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java @@ -119,7 +119,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition asList(String... patterns) { - return (patterns != null ? Arrays.asList(patterns) : Collections.emptyList()); + return (patterns != null ? Arrays.asList(patterns) : Collections.emptyList()); } private static Set prependLeadingSlash(Collection patterns) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java index c26b5576170..f63e086f93b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java @@ -62,7 +62,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi private static List asList(RequestMethod... requestMethods) { - return (requestMethods != null ? Arrays.asList(requestMethods) : Collections.emptyList()); + return (requestMethods != null ? Arrays.asList(requestMethods) : Collections.emptyList()); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessor.java index 6fcea9d5489..0bae03b2894 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessor.java @@ -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. @@ -106,7 +106,7 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr protected final Map getUriTemplateVariables(NativeWebRequest request) { Map variables = (Map) request.getAttribute( HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); - return (variables != null ? variables : Collections.emptyMap()); + return (variables != null ? variables : Collections.emptyMap()); } /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java index a3c7ec06041..eeeb7dfd8c7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java @@ -235,7 +235,7 @@ public class SseEmitter extends ResponseBodyEmitter { @Override public Set build() { if ((this.sb == null || this.sb.length() == 0) && this.dataToSend.isEmpty()) { - return Collections.emptySet(); + return Collections.emptySet(); } append("\n"); saveAppendedText(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java index 00e678f136a..0b6cc3dc042 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java @@ -405,7 +405,7 @@ public class FreeMarkerView extends AbstractTemplateView { @Override public Enumeration getInitParameterNames() { - return Collections.enumeration(Collections.emptySet()); + return Collections.enumeration(Collections.emptySet()); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java index 10b0743bc1d..362747159a3 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java @@ -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 specialHeaders = new HashSet<>(); static { @@ -60,11 +58,14 @@ public abstract class AbstractWebSocketClient implements WebSocketClient { } + protected final Log logger = LogFactory.getLog(getClass()); + + @Override public ListenableFuture 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 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 subProtocols = ((headers != null) && (headers.getSecWebSocketProtocol() != null)) ? - headers.getSecWebSocketProtocol() : Collections.emptyList(); + List subProtocols = (headers != null && headers.getSecWebSocketProtocol() != null ? + headers.getSecWebSocketProtocol() : Collections.emptyList()); - List extensions = ((headers != null) && (headers.getSecWebSocketExtensions() != null)) ? - headers.getSecWebSocketExtensions() : Collections.emptyList(); + List extensions = (headers != null && headers.getSecWebSocketExtensions() != null ? + headers.getSecWebSocketExtensions() : Collections.emptyList()); return doHandshakeInternal(webSocketHandler, headersToUse, uri, subProtocols, extensions, - Collections.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 doHandshakeInternal(WebSocketHandler webSocketHandler, diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java index 5dca8363391..3c0a9d24a80 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java @@ -468,7 +468,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif } public List> decode(WebSocketMessage webSocketMessage) { - List> result = Collections.>emptyList(); + List> result = Collections.emptyList(); ByteBuffer byteBuffer; if (webSocketMessage instanceof TextMessage) { byteBuffer = ByteBuffer.wrap(((TextMessage) webSocketMessage).asBytes()); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java index 0b9ef34f360..08ae9746eae 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java @@ -66,7 +66,7 @@ public class UndertowRequestUpgradeStrategy extends AbstractStandardUpgradeStrat StringBuffer requestUrl = servletRequest.getRequestURL(); String path = servletRequest.getRequestURI(); // shouldn't matter - Map pathParams = Collections.emptyMap(); + Map pathParams = Collections.emptyMap(); ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint); endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol)); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java index da25b311cbe..9cdd836e8a7 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java @@ -367,7 +367,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life if (handlerToCheck instanceof SubProtocolCapable) { subProtocols = ((SubProtocolCapable) handlerToCheck).getSubProtocols(); } - return (subProtocols != null ? subProtocols : Collections.emptyList()); + return (subProtocols != null ? subProtocols : Collections.emptyList()); } /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java index 3ffd4f7f2b6..87881e06bc1 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeInterceptorChain.java @@ -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 interceptors, WebSocketHandler wsHandler) { - this.interceptors = (interceptors != null ? interceptors : Collections.emptyList()); + this.interceptors = (interceptors != null ? interceptors : Collections.emptyList()); this.wsHandler = wsHandler; }