Replace Collections.unmodifiableList(new ArrayList(..)) with List.copyOf() (#30166)

This commit is contained in:
SW
2023-04-12 20:07:20 +09:00
committed by GitHub
parent 695601aa06
commit 59c65fa940
4 changed files with 4 additions and 7 deletions

View File

@@ -19,7 +19,6 @@ package org.springframework.http.converter;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -100,7 +99,7 @@ public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConv
*/
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
this.supportedMediaTypes = Collections.unmodifiableList(new ArrayList<>(supportedMediaTypes));
this.supportedMediaTypes = List.copyOf(supportedMediaTypes);
}
@Override

View File

@@ -949,7 +949,7 @@ final class HierarchicalUriComponents extends UriComponents {
public PathSegmentComponent(List<String> pathSegments) {
Assert.notNull(pathSegments, "List must not be null");
this.pathSegments = Collections.unmodifiableList(new ArrayList<>(pathSegments));
this.pathSegments = List.copyOf(pathSegments);
}
@Override