Re: RFR: 8281289: Improve with List.copyOf
On Fri, 4 Feb 2022 23:02:21 GMT, Xue-Lei Andrew Fan wrote: > Please review this trivial code clean up, for a little bit better performance. There's a small compatibility risk with this change, e.g., `List.copyOf(...).contains(null)` will throw NPE while `Collections.unmodifiableList(...).contains(null)` won't. If we accept that compatibility risk (which should probably be decided by CSR) it might also make sense to use `List.of()` for the empty case, which will reduce the number of List implementation classes returned from the API. - PR: https://git.openjdk.java.net/jdk/pull/7356
Re: RFR: 8281289: Improve with List.copyOf
On Sat, 5 Feb 2022 13:22:25 GMT, Claes Redestad wrote: > There's a small compatibility risk with this change, e.g., > `List.copyOf(...).contains(null)` will throw NPE while > `Collections.unmodifiableList(...).contains(null)` won't. > > If we accept that compatibility risk (which should probably be decided by > CSR) it might also make sense to use `List.of()` for the empty case, which > will reduce the number of List implementation classes returned from the API. All GOOD points! Thanks! I filed a new JDK-8281298, and a new [pull request](https://github.com/openjdk/jdk/pull/7359). - PR: https://git.openjdk.java.net/jdk/pull/7356
RFR: 8281298: Revise the creation of unmodifiable list
In [JDK-8281289](https://bugs.openjdk.java.net/browse/JDK-8281289), the SSLParameters class was updated with the patch: - return Collections.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