From 63e7523a6de63c3933a3ff1f9de5dcb0281f7fee Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Wed, 3 Apr 2024 11:05:02 +0200 Subject: [PATCH] Avoid unnecessary updates to the sessions during refreshes of tokens Closes #28388 Signed-off-by: Alexander Schwartz --- .../infinispan/AuthenticatedClientSessionAdapter.java | 4 ++++ .../models/sessions/infinispan/UserSessionAdapter.java | 10 ++++++++++ .../PersistentAuthenticatedClientSessionAdapter.java | 3 +++ .../models/session/PersistentUserSessionAdapter.java | 3 +++ .../models/AuthenticatedClientSessionModel.java | 5 +++++ .../java/org/keycloak/models/UserSessionModel.java | 4 ++++ 6 files changed, 29 insertions(+) diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/AuthenticatedClientSessionAdapter.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/AuthenticatedClientSessionAdapter.java index cf44e6b244..5b7197bbcf 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/AuthenticatedClientSessionAdapter.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/AuthenticatedClientSessionAdapter.java @@ -136,6 +136,10 @@ public class AuthenticatedClientSessionAdapter implements AuthenticatedClientSes @Override public void setTimestamp(int timestamp) { + if (timestamp <= getTimestamp()) { + return; + } + ClientSessionUpdateTask task = new ClientSessionUpdateTask() { @Override diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/UserSessionAdapter.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/UserSessionAdapter.java index 146873952d..bccbf98df5 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/UserSessionAdapter.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/UserSessionAdapter.java @@ -158,6 +158,7 @@ public class UserSessionAdapter this.clientSessionUpdateTx.addTask(clientSessionId, Tasks.removeSync())); } + @Override public String getId() { return entity.getId(); } @@ -177,6 +178,7 @@ public class UserSessionAdapter