8289274: Cleanup unnecessary null comparison before instanceof check in security modules

Reviewed-by: mullan
This commit is contained in:
Andrey Turbanov 2022-07-09 17:59:43 +00:00
parent 81ee7d28f8
commit 87aa3ce03e
14 changed files with 54 additions and 94 deletions

View file

@ -915,9 +915,8 @@ final class P11KeyStore extends KeyStoreSpi {
token.ensureValid();
if (protParam != null &&
protParam instanceof KeyStore.PasswordProtection &&
((KeyStore.PasswordProtection)protParam).getPassword() != null &&
if (protParam instanceof PasswordProtection pp &&
pp.getPassword() != null &&
!token.config.getKeyStoreCompatibilityMode()) {
throw new KeyStoreException("ProtectionParameter must be null");
}
@ -1018,9 +1017,8 @@ final class P11KeyStore extends KeyStoreSpi {
token.ensureValid();
checkWrite();
if (protParam != null &&
protParam instanceof KeyStore.PasswordProtection &&
((KeyStore.PasswordProtection)protParam).getPassword() != null &&
if (protParam instanceof PasswordProtection pp &&
pp.getPassword() != null &&
!token.config.getKeyStoreCompatibilityMode()) {
throw new KeyStoreException(new UnsupportedOperationException
("ProtectionParameter must be null"));