From 75acc277064b8fe1a699e6744ca7c4754388bcb8 Mon Sep 17 00:00:00 2001 From: mduchrow Date: Fri, 27 Mar 2020 08:15:03 +0100 Subject: [PATCH] KEYCLOAK-13339 NPE when removing credentials and user cache is disabled --- .../org/keycloak/credential/UserCredentialStoreManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/src/main/java/org/keycloak/credential/UserCredentialStoreManager.java b/services/src/main/java/org/keycloak/credential/UserCredentialStoreManager.java index 7c35fc9263..377c4e5afd 100644 --- a/services/src/main/java/org/keycloak/credential/UserCredentialStoreManager.java +++ b/services/src/main/java/org/keycloak/credential/UserCredentialStoreManager.java @@ -74,7 +74,10 @@ public class UserCredentialStoreManager implements UserCredentialManager, OnUser public boolean removeStoredCredential(RealmModel realm, UserModel user, String id) { throwExceptionIfInvalidUser(user); 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; }