Close stream

This commit is contained in:
Brendan Le Ny 2024-06-24 15:46:56 +02:00 committed by Alex Morel
parent 54a2f10114
commit 51d4837c19

View file

@ -41,10 +41,14 @@ public class GroupScimService extends AbstractScimService<GroupModel, Group> {
Set<String> names = new TreeSet<>();
resource.getId().ifPresent(names::add);
resource.getDisplayName().ifPresent(names::add);
Optional<GroupModel> group = getKeycloakDao().getGroupsStream()
.filter(groupModel -> names.contains(groupModel.getName()))
.findFirst();
return group.map(GroupModel::getId).map(KeycloakId::new);
try (Stream<GroupModel> groupsStream = getKeycloakDao().getGroupsStream()) {
Optional<GroupModel> group = groupsStream
.filter(groupModel -> names.contains(groupModel.getName()))
.findFirst();
return group
.map(GroupModel::getId)
.map(KeycloakId::new);
}
}
@Override