Reset copiedRanks at the end of each iteration in User#getRanksScoped. This is a fix for an issue where the Iterator#remove call used here would fail if there was more than one other conflicting grants. We change this method to use a Set#remove to prevent the issues caused by trying to call Iterator#remove() multiple times and throwing an IllegalStateException.
This commit is contained in:
parent
cf045e2a49
commit
07b503504a
@ -611,17 +611,12 @@ public final class User {
|
||||
return ImmutableList.of(Rank.findById("default"));
|
||||
}
|
||||
|
||||
Iterator<Rank> iterator = grantedRanks.iterator();
|
||||
Set<Rank> copiedRanks = ImmutableSet.copyOf(grantedRanks);
|
||||
|
||||
// This is to remove redundant ranks. Say they have mod, mod-plus, admin, and youtuber,
|
||||
// we should remove mod and mod-plus as it'll be made redundant by the higher ranked admin.
|
||||
while (iterator.hasNext()) {
|
||||
Rank rank = iterator.next();
|
||||
|
||||
for (Rank grantedRank : ImmutableSet.copyOf(grantedRanks)) {
|
||||
// Check all other ranks for inherited collision
|
||||
for (Rank otherRank : copiedRanks) {
|
||||
if (otherRank == rank) {
|
||||
for (Rank otherRank : ImmutableSet.copyOf(grantedRanks)) {
|
||||
if (grantedRank == otherRank) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -629,8 +624,8 @@ public final class User {
|
||||
|
||||
// Iterate up the inheritance tree to detect rank redundancies.
|
||||
while (parent.getInheritsFromId() != null) {
|
||||
if (parent == rank) {
|
||||
iterator.remove();
|
||||
if (parent == grantedRank) {
|
||||
grantedRanks.remove(grantedRank);
|
||||
}
|
||||
|
||||
parent = Rank.findById(parent.getInheritsFromId());
|
||||
|
Loading…
Reference in New Issue
Block a user