On Fri, 8 Mar 2024 23:09:42 GMT, Hai-May Chao <[email protected]> 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