RFR: 8314199: Initial size PBEKeyFactory#validTypes is not up-to-date
Jamil Nimeh
jnimeh at openjdk.org
Mon Oct 9 17:03:58 UTC 2023
On Mon, 9 Oct 2023 16:36:06 GMT, Kevin Driver <kdriver at openjdk.org> wrote:
> fixes [JDK-8314199](https://bugs.openjdk.org/browse/JDK-8314199) by initializing the HashSet with a more accurate number
src/java.base/share/classes/com/sun/crypto/provider/PBEKeyFactory.java line 59:
> 57:
> 58: static {
> 59: validTypes = HashSet.newHashSet(21);
Rather than having to change the initial size and keep it synchronized with all the subsequent adds, could we just change the type of `validTypes` to `Set<String>` and initialize it using `Set.of(E...)`? It seems like that would allow you to set all the values directly in the declaration up on line 49, would remove the need for the static block and I think you could even declare validTypes final, couldn't you? And any new additions to the set could simply be added and not worry about setting an accurate count in the constructor.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16103#discussion_r1350563277
More information about the security-dev
mailing list