RFR: 8327461: KeyStore getEntry is not thread-safe [v6]
Weijun Wang
weijun at openjdk.org
Fri Mar 8 23:21:57 UTC 2024
On Fri, 8 Mar 2024 23:09:42 GMT, Hai-May Chao <hchao at openjdk.org> wrote:
>> src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java line 1027:
>>
>>> 1025:
>>> 1026: Entry entry = entries.remove(alias.toLowerCase(Locale.ENGLISH));
>>> 1027: if (entry != null) {
>>
>> No need to check `entry != null`.
>
> The API doc states: Returns: the previous value associated with key, or null if there was no mapping for key. It’d be a good practice to check if the entry is not null before proceeding with further operations. Would you please elaborate why it is not needed here?
Because `null` will fail all three `instanceof` checks.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18156#discussion_r1518404259
More information about the security-dev
mailing list