From 673e122443f3bd535563a28e50ca55bdb63d0ff7 Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Mon, 6 May 2024 16:55:50 +0200 Subject: [PATCH] Avoid sorting items returned from the database which are already stable Closes #29319 Signed-off-by: Alexander Schwartz --- .../sessions/infinispan/PersistentUserSessionProvider.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/PersistentUserSessionProvider.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/PersistentUserSessionProvider.java index 7b2edefe9e..5e21d0f795 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/PersistentUserSessionProvider.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/PersistentUserSessionProvider.java @@ -68,7 +68,6 @@ import org.keycloak.models.utils.UserModelDelegate; import java.nio.charset.StandardCharsets; import java.util.Collection; -import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -397,8 +396,7 @@ public class PersistentUserSessionProvider implements UserSessionProvider, Sessi protected Stream getUserSessionsStream(final RealmModel realm, ClientModel client, Integer firstResult, Integer maxResults, final boolean offline) { UserSessionPredicate predicate = UserSessionPredicate.create(realm.getId()).client(client.getId()); - return paginatedStream(getUserSessionsStream(realm, predicate, offline) - .sorted(Comparator.comparing(UserSessionModel::getLastSessionRefresh)), firstResult, maxResults); + return paginatedStream(getUserSessionsStream(realm, predicate, offline), firstResult, maxResults); } @Override