From c793c138a3ff51c79188f9803a824994eb35db79 Mon Sep 17 00:00:00 2001 From: Brendan Le Ny Date: Fri, 21 Jun 2024 10:45:48 +0200 Subject: [PATCH] Fix concurrent modification exception with dispatcher caching keycloak-1 | 2024-06-21 08:32:21,335 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-9) Uncaught server error: java.util.ConcurrentModificationException keycloak-1 | at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221) keycloak-1 | at sh.libre.scim.core.ScimDispatcher.createForSession(ScimDispatcher.java:31) keycloak-1 | at sh.libre.scim.event.ScimEventListenerProvider.(ScimEventListenerProvider.java:49) keycloak-1 | at sh.libre.scim.event.ScimEventListenerProviderFactory.create(ScimEventListenerProviderFactory.java:13) keycloak-1 | at sh.libre.scim.event.ScimEventListenerProviderFactory.create(ScimEventListenerProviderFactory.java:9) keycloak-1 | at org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:195) --- src/main/java/sh/libre/scim/core/ScimDispatcher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/sh/libre/scim/core/ScimDispatcher.java b/src/main/java/sh/libre/scim/core/ScimDispatcher.java index 7db4e62938..c46740df9c 100644 --- a/src/main/java/sh/libre/scim/core/ScimDispatcher.java +++ b/src/main/java/sh/libre/scim/core/ScimDispatcher.java @@ -10,6 +10,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; /** @@ -19,7 +20,7 @@ public class ScimDispatcher { private static final Logger logger = Logger.getLogger(ScimDispatcher.class); - private static final Map sessionToScimDispatcher = new LinkedHashMap<>(); + private static final Map sessionToScimDispatcher = new ConcurrentHashMap<>(); private final KeycloakSession session; private boolean clientsInitialized = false; private final List userScimServices = new ArrayList<>();