Skip to content

Commit 59c65fa

Browse files
authored
Replace Collections.unmodifiableList(new ArrayList(..)) with List.copyOf() (#30166)
1 parent 695601a commit 59c65fa

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/reactive/PayloadMethodArgumentResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.messaging.handler.annotation.reactive;
1818

1919
import java.lang.annotation.Annotation;
20-
import java.util.ArrayList;
2120
import java.util.Collections;
2221
import java.util.List;
2322
import java.util.Map;
@@ -93,7 +92,7 @@ public PayloadMethodArgumentResolver(List<? extends Decoder<?>> decoders, @Nulla
9392
@Nullable ReactiveAdapterRegistry registry, boolean useDefaultResolution) {
9493

9594
Assert.isTrue(!CollectionUtils.isEmpty(decoders), "At least one Decoder is required");
96-
this.decoders = Collections.unmodifiableList(new ArrayList<>(decoders));
95+
this.decoders = List.copyOf(decoders);
9796
this.validator = validator;
9897
this.adapterRegistry = registry != null ? registry : ReactiveAdapterRegistry.getSharedInstance();
9998
this.useDefaultResolution = useDefaultResolution;

spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultMetadataExtractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.messaging.rsocket;
1818

19-
import java.util.ArrayList;
2019
import java.util.Arrays;
2120
import java.util.Collections;
2221
import java.util.HashMap;
@@ -73,7 +72,7 @@ public DefaultMetadataExtractor(Decoder<?>... decoders) {
7372
* Constructor with list of decoders for de-serializing metadata entries.
7473
*/
7574
public DefaultMetadataExtractor(List<Decoder<?>> decoders) {
76-
this.decoders = Collections.unmodifiableList(new ArrayList<>(decoders));
75+
this.decoders = List.copyOf(decoders);
7776
}
7877

7978

spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020
import java.io.OutputStream;
2121
import java.nio.charset.Charset;
22-
import java.util.ArrayList;
2322
import java.util.Arrays;
2423
import java.util.Collections;
2524
import java.util.List;
@@ -100,7 +99,7 @@ protected AbstractHttpMessageConverter(Charset defaultCharset, MediaType... supp
10099
*/
101100
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
102101
Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
103-
this.supportedMediaTypes = Collections.unmodifiableList(new ArrayList<>(supportedMediaTypes));
102+
this.supportedMediaTypes = List.copyOf(supportedMediaTypes);
104103
}
105104

106105
@Override

spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ static final class PathSegmentComponent implements PathComponent {
949949

950950
public PathSegmentComponent(List<String> pathSegments) {
951951
Assert.notNull(pathSegments, "List must not be null");
952-
this.pathSegments = Collections.unmodifiableList(new ArrayList<>(pathSegments));
952+
this.pathSegments = List.copyOf(pathSegments);
953953
}
954954

955955
@Override

0 commit comments

Comments
 (0)