From 993d9105208e3f027168f003e5235cbe9bed9a7e Mon Sep 17 00:00:00 2001 From: zak905 Date: Mon, 20 Dec 2021 21:45:45 +0100 Subject: [PATCH] avoid NPE in LegacyAttributes when using federated storage Closes #https://github.com/keycloak/keycloak/issues/15482 --- .../org/keycloak/userprofile/LegacyAttributes.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/services/src/main/java/org/keycloak/userprofile/LegacyAttributes.java b/services/src/main/java/org/keycloak/userprofile/LegacyAttributes.java index eaba623287..0c0aa44af1 100644 --- a/services/src/main/java/org/keycloak/userprofile/LegacyAttributes.java +++ b/services/src/main/java/org/keycloak/userprofile/LegacyAttributes.java @@ -40,16 +40,10 @@ public class LegacyAttributes extends DefaultAttributes { @Override public Map> getReadable() { - if(user == null) - return null; + if(user == null || user.getAttributes() == null) + return new HashMap<>(); - Map> attributes = new HashMap<>(user.getAttributes()); - - if (attributes.isEmpty()) { - return null; - } - - return attributes; + return new HashMap<>(user.getAttributes()); } @Override