RFR: 8281298: Revise the creation of unmodifiable list

Xue-Lei Andrew Fan xuelei at openjdk.java.net
Sat Feb 5 20:36:36 UTC 2022


In [JDK-8281289](https://bugs.openjdk.java.net/browse/JDK-8281289), the SSLParameters class was updated with the patch:

- return Collections.<SNIServerName>unmodifiableList(new ArrayList<>(sniNames.values()));
+ return List.copyOf(sniNames.values());

However, there's a small compatibility risk with this change, `List.copyOf(...).contains(null)` will throw NPE while `Collections.unmodifiableList(...).contains(null)` won't. It may be not worthy of the risk although the impact may be minimal.

This update will re-use the Collections.unmodifiableList() methods, but re-org the code for better performance.

-------------

Commit messages:
 - 8281298: Revise the creation of unmodifiable list

Changes: https://git.openjdk.java.net/jdk/pull/7359/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7359&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8281298
  Stats: 71 lines in 1 file changed: 18 ins; 25 del; 28 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7359.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7359/head:pull/7359

PR: https://git.openjdk.java.net/jdk/pull/7359



More information about the security-dev mailing list