From 93419a1797d0e24fc149a26f3cbac2e919d4245a Mon Sep 17 00:00:00 2001 From: Dominik DS <12406359+domids@users.noreply.github.com> Date: Wed, 12 Jan 2022 09:22:01 +0100 Subject: [PATCH] KEYCLOAK-19289 check if values to set is not null (#8426) Closes #9529 --- .../src/main/java/org/keycloak/models/jpa/UserAdapter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/UserAdapter.java b/model/jpa/src/main/java/org/keycloak/models/jpa/UserAdapter.java index 020b5b8a71..c98fcf6eeb 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/UserAdapter.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/UserAdapter.java @@ -175,8 +175,10 @@ public class UserAdapter implements UserModel.Streams, JpaModel { } // Remove all existing removeAttribute(name); - for (Iterator it = values.stream().filter(Objects::nonNull).iterator(); it.hasNext();) { - persistAttributeValue(name, it.next()); + if (values != null) { + for (Iterator it = values.stream().filter(Objects::nonNull).iterator(); it.hasNext();) { + persistAttributeValue(name, it.next()); + } } }