From 52529923841376eb87915c7485d5d0cb78ace4ad Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Mon, 20 Mar 2023 14:22:01 +0100 Subject: [PATCH] Workaround to avoid replacing element collections Relates to #19162 --- .../models/jpa/entities/ClientEntity.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java index 6535e26e87..1ec4d83bd4 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientEntity.java @@ -226,7 +226,14 @@ public class ClientEntity { } public void setWebOrigins(Set webOrigins) { - this.webOrigins = webOrigins; + // Workaround to avoid a problem in Hibernate 6.2.CR3: https://hibernate.atlassian.net/browse/HHH-16337 + // Tracked via GitHub issue: https://github.com/keycloak/keycloak/issues/19162 + if (this.webOrigins != null) { + this.webOrigins.clear(); + this.webOrigins.addAll(webOrigins); + } else { + this.webOrigins = webOrigins; + } } public Set getRedirectUris() { @@ -237,7 +244,14 @@ public class ClientEntity { } public void setRedirectUris(Set redirectUris) { - this.redirectUris = redirectUris; + // Workaround to avoid a problem in Hibernate 6.2.CR3: https://hibernate.atlassian.net/browse/HHH-16337 + // Tracked via GitHub issue: https://github.com/keycloak/keycloak/issues/19162 + if (this.redirectUris != null) { + this.redirectUris.clear(); + this.redirectUris.addAll(redirectUris); + } else { + this.redirectUris = redirectUris; + } } public String getClientAuthenticatorType() {