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<>(); Set<String> names = new TreeSet<>();
resource.getId().ifPresent(names::add); resource.getId().ifPresent(names::add);
resource.getDisplayName().ifPresent(names::add); resource.getDisplayName().ifPresent(names::add);
Optional<GroupModel> group = getKeycloakDao().getGroupsStream() try (Stream<GroupModel> groupsStream = getKeycloakDao().getGroupsStream()) {
.filter(groupModel -> names.contains(groupModel.getName())) Optional<GroupModel> group = groupsStream
.findFirst(); .filter(groupModel -> names.contains(groupModel.getName()))
return group.map(GroupModel::getId).map(KeycloakId::new); .findFirst();
return group
.map(GroupModel::getId)
.map(KeycloakId::new);
}
} }
@Override @Override