Missing null check for session.userCache() added

NPE when existing user from LDAP is found (same LDAP_ID, but with changed username) and session.userCache() is null.
This commit is contained in:
cturkalj 2021-06-18 14:22:07 +02:00 committed by Marek Posolda
parent 1ad34c6ab0
commit b4536a394a

View file

@ -525,7 +525,9 @@ public class LDAPStorageProvider implements UserStorageProvider,
if(existingLocalUser != null){ if(existingLocalUser != null){
imported = existingLocalUser; imported = existingLocalUser;
// Need to evict the existing user from cache // Need to evict the existing user from cache
session.userCache().evict(realm, existingLocalUser); if (session.userCache() != null) {
session.userCache().evict(realm, existingLocalUser);
}
} else { } else {
imported = session.userLocalStorage().addUser(realm, ldapUsername); imported = session.userLocalStorage().addUser(realm, ldapUsername);
} }