RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping
Xue-Lei Andrew Fan
xuelei at openjdk.org
Wed Jul 26 06:15:39 UTC 2023
On Tue, 25 Jul 2023 06:27:25 GMT, John Jiang <jjiang at openjdk.org> wrote:
> Some java/security classes apply the below coding style,
>
> Set<T> set = ...;
> Set<T> unmodifiableSet = Collections.unmodifiableSet(new HashSet<>(set));
>
> It may be unnecessary to wrap that `set` with HashSet before creating `unmodifiableSet`.
> Some usages on `Collections.unmodifiableList` and `Collections.unmodifiableMap` have the same issue.
Marked as reviewed by xuelei (Reviewer).
Note: Please don't backport this update unless [JDK-6323374](https://bugs.openjdk.org/browse/JDK-6323374) is backport as well.
-------------
PR Review: https://git.openjdk.org/jdk/pull/15008#pullrequestreview-1546896379
PR Comment: https://git.openjdk.org/jdk/pull/15008#issuecomment-1651039887
More information about the security-dev
mailing list