diff --git a/model/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java b/model/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java index 0d3a7bf2ac3e..42d96a265f09 100755 --- a/model/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java +++ b/model/jpa/src/main/java/org/keycloak/events/jpa/JpaEventStoreProvider.java @@ -17,8 +17,6 @@ package org.keycloak.events.jpa; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import org.jboss.logging.Logger; import org.keycloak.common.util.Time; import org.keycloak.events.Event; @@ -37,6 +35,8 @@ import jakarta.persistence.EntityManager; import jakarta.persistence.TypedQuery; +import org.keycloak.util.JsonSerialization; + import java.io.IOException; import java.util.List; import java.util.Map; @@ -49,9 +49,6 @@ */ public class JpaEventStoreProvider implements EventStoreProvider { - private static final ObjectMapper mapper = new ObjectMapper(); - private static final TypeReference> mapType = new TypeReference>() { - }; private static final Logger logger = Logger.getLogger(JpaEventStoreProvider.class); private final KeycloakSession session; @@ -264,7 +261,7 @@ protected void clearExpiredAdminEvents() { private static void setDetails(Consumer setter, Map details) { if (details != null) { try { - setter.accept(mapper.writeValueAsString(details)); + setter.accept(JsonSerialization.writeValueAsString(details)); } catch (IOException e) { logger.error("Failed to write event details", e); } @@ -274,7 +271,7 @@ private static void setDetails(Consumer setter, Map deta private static void setDetails(Consumer> setter, String details) { if (details != null) { try { - setter.accept(mapper.readValue(details, mapType)); + setter.accept(JsonSerialization.readValue(details, Map.class)); } catch (IOException e) { logger.error("Failed to read event details", e); }