KEYCLOAK-13339 NPE when removing credentials and user cache is disabled

This commit is contained in:
mduchrow 2020-03-27 08:15:03 +01:00 committed by Hynek Mlnařík
parent 6f62c0ed98
commit 75acc27706

View file

@ -74,7 +74,10 @@ public class UserCredentialStoreManager implements UserCredentialManager, OnUser
public boolean removeStoredCredential(RealmModel realm, UserModel user, String id) { public boolean removeStoredCredential(RealmModel realm, UserModel user, String id) {
throwExceptionIfInvalidUser(user); throwExceptionIfInvalidUser(user);
boolean removalResult = getStoreForUser(user).removeStoredCredential(realm, user, id); boolean removalResult = getStoreForUser(user).removeStoredCredential(realm, user, id);
session.userCache().evict(realm, user); UserCache userCache = session.userCache();
if (userCache != null) {
userCache.evict(realm, user);
}
return removalResult; return removalResult;
} }