Replace use of Collections.unmodifiable*() methods where appropriate
Closes gh-29321
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.function.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -88,7 +86,7 @@ final class DefaultExchangeStrategiesBuilder implements ExchangeStrategies.Build
|
||||
}
|
||||
|
||||
private static <T> List<T> unmodifiableCopy(List<? extends T> list) {
|
||||
return Collections.unmodifiableList(new ArrayList<>(list));
|
||||
return List.copyOf(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.function.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -135,7 +134,7 @@ class DefaultHandlerStrategiesBuilder implements HandlerStrategies.Builder {
|
||||
}
|
||||
|
||||
private static <T> List<T> unmodifiableCopy(List<? extends T> list) {
|
||||
return Collections.unmodifiableList(new ArrayList<>(list));
|
||||
return List.copyOf(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -171,7 +171,7 @@ final class DefaultRenderingResponseBuilder implements RenderingResponse.Builder
|
||||
|
||||
super(statusCode, headers, cookies, Collections.emptyMap());
|
||||
this.name = name;
|
||||
this.model = Collections.unmodifiableMap(new LinkedHashMap<>(model));
|
||||
this.model = Map.copyOf(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -88,7 +87,7 @@ class DefaultServerRequest implements ServerRequest {
|
||||
|
||||
DefaultServerRequest(ServerWebExchange exchange, List<HttpMessageReader<?>> messageReaders) {
|
||||
this.exchange = exchange;
|
||||
this.messageReaders = Collections.unmodifiableList(new ArrayList<>(messageReaders));
|
||||
this.messageReaders = List.copyOf(messageReaders);
|
||||
this.headers = new DefaultHeaders();
|
||||
}
|
||||
|
||||
|
||||
@@ -1175,7 +1175,7 @@ public abstract class RouterFunctions {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
else {
|
||||
return Collections.unmodifiableMap(new LinkedHashMap<>(attributes));
|
||||
return Map.copyOf(attributes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,9 +107,8 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||
public Map<T, HandlerMethod> getHandlerMethods() {
|
||||
this.mappingRegistry.acquireReadLock();
|
||||
try {
|
||||
return Collections.unmodifiableMap(
|
||||
this.mappingRegistry.getRegistrations().entrySet().stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().handlerMethod)));
|
||||
return this.mappingRegistry.getRegistrations().entrySet().stream()
|
||||
.collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, entry -> entry.getValue().handlerMethod));
|
||||
}
|
||||
finally {
|
||||
this.mappingRegistry.releaseReadLock();
|
||||
|
||||
Reference in New Issue
Block a user