Graceful handling if composite roles have been removed concurrently.

Closes #12003
This commit is contained in:
Alexander Schwartz 2022-05-16 09:49:26 +02:00 committed by Hynek Mlnařík
parent 0bda7e6038
commit 1a95a58893

View file

@ -130,14 +130,15 @@ public class RoleAdapter implements RoleModel {
if (composites == null) {
composites = new HashSet<>();
composites = cached.getComposites().stream()
.map(id -> {
RoleModel role = realm.getRoleById(id);
if (role == null) {
throw new IllegalStateException("Could not find composite in role " + getName() + ": " + id);
}
return role;
}).collect(Collectors.toSet());
for (String id : cached.getComposites()) {
RoleModel role = realm.getRoleById(id);
if (role == null) {
// chance that composite role was removed, so invalidate this entry and fallback to delegate
getDelegateForUpdate();
return updated.getCompositesStream();
}
composites.add(role);
}
}
return composites.stream();