RFR: 8314199: Initial size PBEKeyFactory#validTypes is not up-to-date
Kevin Driver
kdriver at openjdk.org
Mon Oct 9 19:03:01 UTC 2023
On Mon, 9 Oct 2023 17:00:45 GMT, Jamil Nimeh <jnimeh 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.
I wondered about an approach like this. I'll push another commit with these changes.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16103#discussion_r1350703267
More information about the security-dev
mailing list