RFR: 6447816: Provider filtering (getProviders) is not working with OR'd conditions [v2]

Weijun Wang weijun at openjdk.org
Tue Sep 6 14:13:44 UTC 2022


On Thu, 25 Aug 2022 19:59:18 GMT, Valerie Peng <valeriep at openjdk.org> wrote:

>> src/java.base/share/classes/java/security/Security.java line 599:
>> 
>>> 597:         // Returns all installed providers
>>> 598:         // if the selection criteria is null.
>>> 599:         if ((keySet == null) || (allProviders == null)) {
>> 
>> I'm not sure, but can `keySet` or `allProviders` be null? Or you meant `isEmpty()`?
>
> Both may be null as their javadoc didn't state explicitly what is returned.
> This is existing code and it returns null upon empty keySet which I keep the same behavior. 
> Perhaps for consistency sake, it should also check for the empty keySet condition and return allProviders.

Sorry, I re-read and maybe the original check is better. If both `keySet` and `allProviders` are empty, then empty is returned. According to the spec, it should be null.

I still don't think either of them can be null, but adding the `isEmpty` check is probably wrong.

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

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



More information about the security-dev mailing list