8281289: Improve with List.copyOf

Reviewed-by: jnimeh, hchao
This commit is contained in:
Xue-Lei Andrew Fan 2022-02-05 07:44:57 +00:00
parent 48523b0908
commit 42e272e181

View file

@ -29,7 +29,6 @@ import java.security.AlgorithmConstraints;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.util.HashMap; import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -391,8 +390,7 @@ public class SSLParameters {
public final List<SNIServerName> getServerNames() { public final List<SNIServerName> getServerNames() {
if (sniNames != null) { if (sniNames != null) {
if (!sniNames.isEmpty()) { if (!sniNames.isEmpty()) {
return Collections.<SNIServerName>unmodifiableList( return List.copyOf(sniNames.values());
new ArrayList<>(sniNames.values()));
} else { } else {
return Collections.<SNIServerName>emptyList(); return Collections.<SNIServerName>emptyList();
} }
@ -466,8 +464,7 @@ public class SSLParameters {
public final Collection<SNIMatcher> getSNIMatchers() { public final Collection<SNIMatcher> getSNIMatchers() {
if (sniMatchers != null) { if (sniMatchers != null) {
if (!sniMatchers.isEmpty()) { if (!sniMatchers.isEmpty()) {
return Collections.<SNIMatcher>unmodifiableList( return List.copyOf(sniMatchers.values());
new ArrayList<>(sniMatchers.values()));
} else { } else {
return Collections.<SNIMatcher>emptyList(); return Collections.<SNIMatcher>emptyList();
} }