RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping [v2]
Sean Mullan
mullan at openjdk.org
Wed Jul 26 19:12:55 UTC 2023
On Wed, 26 Jul 2023 09:28:46 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.
>
> John Jiang has updated the pull request incrementally with one additional commit since the last revision:
>
> use copyOf instead of modifiableXXX
src/java.base/share/classes/java/security/KeyStore.java line 769:
> 767: }
> 768: this.cert = trustedCert;
> 769: this.attributes = Set.copyOf(attributes);
Similar comments.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15008#discussion_r1275083599
More information about the security-dev
mailing list