RFR: 8312630: java/security should not create unmodifiable collections with redundant wrapping

John Jiang jjiang at openjdk.org
Tue Jul 25 06:33:58 UTC 2023


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.

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

Commit messages:
 - 8312630: java/security should not create unmodifiable collections with redundant wrapping

Changes: https://git.openjdk.org/jdk/pull/15008/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15008&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8312630
  Stats: 20 lines in 4 files changed: 0 ins; 7 del; 13 mod
  Patch: https://git.openjdk.org/jdk/pull/15008.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15008/head:pull/15008

PR: https://git.openjdk.org/jdk/pull/15008


More information about the security-dev mailing list