[jdk18] RFR: 8279222: Incorrect legacyMap.get in java.security.Provider after JDK-8276660

Alan Bateman alanb at openjdk.java.net
Thu Dec 23 13:46:12 UTC 2021


On Thu, 23 Dec 2021 13:33:26 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> SonarCloud reports:
>  A "Map<ServiceKey, Service>" cannot contain a "String" in a "ServiceKey" type.
> 
> 
>      // clean up old alias if present
>      Service prevAliasService = legacyMap.get(aliasAlg);
> 
> 
> Should be `aliasKey`, like other accesses to `legacyMap`. This code is introduced by [JDK-8276660](https://bugs.openjdk.java.net/browse/JDK-8276660), so it affects JDK 18.
> 
> Additional testing:
>  - [x] Linux x86_64 fastdebug `jdk_security`

src/java.base/share/classes/java/security/Provider.java line 1152:

> 1150:                 case ADD:
> 1151:                     // clean up old alias if present
> 1152:                     Service prevAliasService = legacyMap.get(aliasKey);

The change looks okay but I'm surprised this wasn't caught by tests. 
@valeriepeng - would it be feasible to have a test that removes an old alias so that this code is exercised by tests?

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

PR: https://git.openjdk.java.net/jdk18/pull/70


More information about the security-dev mailing list