Avoid duplicates when storing organization ids
Signed-off-by: Michal Hajas <mhajas@redhat.com>
This commit is contained in:
parent
0becdaa2a9
commit
c682536dae
1 changed files with 3 additions and 2 deletions
|
@ -19,6 +19,7 @@ package org.keycloak.models.cache.infinispan.organization;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.keycloak.models.OrganizationModel;
|
import org.keycloak.models.OrganizationModel;
|
||||||
|
@ -40,8 +41,8 @@ public class CachedOrganizationIds extends AbstractRevisioned implements InRealm
|
||||||
public CachedOrganizationIds(Long revision, String id, RealmModel realm, Stream<OrganizationModel> models) {
|
public CachedOrganizationIds(Long revision, String id, RealmModel realm, Stream<OrganizationModel> models) {
|
||||||
super(revision, id);
|
super(revision, id);
|
||||||
this.realmId = realm.getId();
|
this.realmId = realm.getId();
|
||||||
var ids = models.map(OrganizationModel::getId).toList();
|
var ids = models.map(OrganizationModel::getId).collect(Collectors.toSet());
|
||||||
orgIds = ids.isEmpty() ? List.of() : ids;
|
orgIds = ids.isEmpty() ? List.of() : List.of(ids.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getOrgIds() {
|
public Collection<String> getOrgIds() {
|
||||||
|
|
Loading…
Reference in a new issue