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) -> {
|
Stream<SessionRepresentation> result = sessionIdStream.flatMap((clientIdSessionType) -> {
|
||||||
ClientModel clientModel = realm.getClientById(clientIdSessionType.getClientId());
|
ClientModel clientModel = realm.getClientById(clientIdSessionType.getClientId());
|
||||||
|
if (clientModel == null) {
|
||||||
|
// client has been removed in the meantime
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
||||||
switch (clientIdSessionType.getType()) {
|
switch (clientIdSessionType.getType()) {
|
||||||
case REGULAR:
|
case REGULAR:
|
||||||
return session.sessions().getUserSessionsStream(realm, clientModel)
|
return session.sessions().getUserSessionsStream(realm, clientModel)
|
||||||
|
|
|
@ -172,10 +172,12 @@ public class SessionResource {
|
||||||
|
|
||||||
for (String clientUUID : s.getAuthenticatedClientSessions().keySet()) {
|
for (String clientUUID : s.getAuthenticatedClientSessions().keySet()) {
|
||||||
ClientModel client = realm.getClientById(clientUUID);
|
ClientModel client = realm.getClientById(clientUUID);
|
||||||
ClientRepresentation clientRep = new ClientRepresentation();
|
if (client != null) {
|
||||||
clientRep.setClientId(client.getClientId());
|
ClientRepresentation clientRep = new ClientRepresentation();
|
||||||
clientRep.setClientName(client.getName());
|
clientRep.setClientId(client.getClientId());
|
||||||
sessionRep.getClients().add(clientRep);
|
clientRep.setClientName(client.getName());
|
||||||
|
sessionRep.getClients().add(clientRep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sessionRep;
|
return sessionRep;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue