Graceful handling if composite roles have been removed concurrently.
Closes #12003
This commit is contained in:
parent
0bda7e6038
commit
1a95a58893
1 changed files with 9 additions and 8 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue