[KEYCLOAK-7239] Fixed ConcurrentModificationException while importing from LDAP with "ignoreMissingGroups" checked.
Fixed test so that now it checks this use case.
This commit is contained in:
parent
5a56a822b0
commit
2bab2acf5b
2 changed files with 7 additions and 4 deletions
|
@ -21,6 +21,7 @@ import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -109,13 +110,15 @@ public class GroupTreeResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Group group : groups) {
|
for (Group group : groups) {
|
||||||
for (String child : group.getChildrenNames()) {
|
Iterator<String> iterator = group.getChildrenNames().iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String child = iterator.next();
|
||||||
List<String> list = result.get(child);
|
List<String> list = result.get(child);
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
list.add(group.getGroupName());
|
list.add(group.getGroupName());
|
||||||
} else if(ignoreMissingGroups){
|
} else if (ignoreMissingGroups) {
|
||||||
// Need to remove the missing group
|
// Need to remove the missing group
|
||||||
group.getChildrenNames().remove(child);
|
iterator.remove();
|
||||||
logger.debug("Group '" + child + "' referenced as member of group '" + group.getGroupName() + "' doesn't exists. Ignoring.");
|
logger.debug("Group '" + child + "' referenced as member of group '" + group.getGroupName() + "' doesn't exists. Ignoring.");
|
||||||
} else {
|
} else {
|
||||||
throw new GroupTreeResolveException("Group '" + child + "' referenced as member of group '" + group.getGroupName() + "' doesn't exists");
|
throw new GroupTreeResolveException("Group '" + child + "' referenced as member of group '" + group.getGroupName() + "' doesn't exists");
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class GroupTreeResolverTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGroupResolvingMissingGroup() throws GroupTreeResolver.GroupTreeResolveException {
|
public void testGroupResolvingMissingGroup() throws GroupTreeResolver.GroupTreeResolveException {
|
||||||
GroupTreeResolver.Group group1 = new GroupTreeResolver.Group("group1", "group2");
|
GroupTreeResolver.Group group1 = new GroupTreeResolver.Group("group1", "group2");
|
||||||
GroupTreeResolver.Group group2 = new GroupTreeResolver.Group("group2", "group3");
|
GroupTreeResolver.Group group2 = new GroupTreeResolver.Group("group2", "group3", "group5");
|
||||||
GroupTreeResolver.Group group4 = new GroupTreeResolver.Group("group4");
|
GroupTreeResolver.Group group4 = new GroupTreeResolver.Group("group4");
|
||||||
List<GroupTreeResolver.Group> groups = Arrays.asList(group1, group2, group4);
|
List<GroupTreeResolver.Group> groups = Arrays.asList(group1, group2, group4);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue