Replace use of Collections.unmodifiable*() methods where appropriate
Closes gh-29321
This commit is contained in:
@@ -19,9 +19,9 @@ package org.springframework.web.socket.server.support;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -95,9 +95,8 @@ public class OriginHandshakeInterceptor implements HandshakeInterceptor {
|
||||
* @since 4.1.5
|
||||
*/
|
||||
public Collection<String> getAllowedOrigins() {
|
||||
List<String> allowedOrigins = this.corsConfiguration.getAllowedOrigins();
|
||||
return (CollectionUtils.isEmpty(allowedOrigins) ? Collections.emptySet() :
|
||||
Collections.unmodifiableSet(new LinkedHashSet<>(allowedOrigins)));
|
||||
return (CollectionUtils.isEmpty(this.corsConfiguration.getAllowedOrigins()) ? Collections.emptySet() :
|
||||
Set.copyOf(this.corsConfiguration.getAllowedOrigins()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,9 +118,8 @@ public class OriginHandshakeInterceptor implements HandshakeInterceptor {
|
||||
* @since 5.3.2
|
||||
*/
|
||||
public Collection<String> getAllowedOriginPatterns() {
|
||||
List<String> allowedOriginPatterns = this.corsConfiguration.getAllowedOriginPatterns();
|
||||
return (CollectionUtils.isEmpty(allowedOriginPatterns) ? Collections.emptySet() :
|
||||
Collections.unmodifiableSet(new LinkedHashSet<>(allowedOriginPatterns)));
|
||||
return (CollectionUtils.isEmpty(this.corsConfiguration.getAllowedOriginPatterns()) ? Collections.emptySet() :
|
||||
Set.copyOf(this.corsConfiguration.getAllowedOriginPatterns()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
package org.springframework.web.socket.sockjs.transport;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -47,15 +46,8 @@ public enum TransportType {
|
||||
HTML_FILE("htmlfile", HttpMethod.GET, "cors", "jsessionid", "no_cache");
|
||||
|
||||
|
||||
private static final Map<String, TransportType> TRANSPORT_TYPES;
|
||||
|
||||
static {
|
||||
Map<String, TransportType> transportTypes = new HashMap<>();
|
||||
for (TransportType type : values()) {
|
||||
transportTypes.put(type.value, type);
|
||||
}
|
||||
TRANSPORT_TYPES = Collections.unmodifiableMap(transportTypes);
|
||||
}
|
||||
private static final Map<String, TransportType> TRANSPORT_TYPES =
|
||||
Arrays.stream(values()).collect(Collectors.toUnmodifiableMap(type -> type.value, type -> type));
|
||||
|
||||
@Nullable
|
||||
public static TransportType fromValue(String value) {
|
||||
|
||||
Reference in New Issue
Block a user