Handle non-existing client gracefully (#32151)
Closes #32150 Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
parent
aeb1951aba
commit
80d235fffb
2 changed files with 10 additions and 4 deletions
|
@ -75,6 +75,10 @@ public class SessionsResource {
|
|||
|
||||
Stream<SessionRepresentation> result = sessionIdStream.flatMap((clientIdSessionType) -> {
|
||||
ClientModel clientModel = realm.getClientById(clientIdSessionType.getClientId());
|
||||
if (clientModel == null) {
|
||||
// client has been removed in the meantime
|
||||
return Stream.empty();
|
||||
}
|
||||
switch (clientIdSessionType.getType()) {
|
||||
case REGULAR:
|
||||
return session.sessions().getUserSessionsStream(realm, clientModel)
|
||||
|
|
|
@ -172,11 +172,13 @@ public class SessionResource {
|
|||
|
||||
for (String clientUUID : s.getAuthenticatedClientSessions().keySet()) {
|
||||
ClientModel client = realm.getClientById(clientUUID);
|
||||
if (client != null) {
|
||||
ClientRepresentation clientRep = new ClientRepresentation();
|
||||
clientRep.setClientId(client.getClientId());
|
||||
clientRep.setClientName(client.getName());
|
||||
sessionRep.getClients().add(clientRep);
|
||||
}
|
||||
}
|
||||
return sessionRep;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue