MapUserProvider should throw an exception for more than one user

Closes #14672
This commit is contained in:
vramik 2022-10-06 09:03:14 +02:00 committed by Hynek Mlnařík
parent a670e1d965
commit a62e98f966

View file

@ -505,8 +505,8 @@ public class MapUserProvider implements UserProvider.Streams {
List<MapUserEntity> users = s.collect(Collectors.toList());
if (users.isEmpty()) return null;
if (users.size() != 1) {
LOG.warnf("There are colliding usernames for users with usernames and ids: %s",
users.stream().collect(Collectors.toMap(MapUserEntity::getUsername, MapUserEntity::getId)));
throw new ModelDuplicateException(String.format("There are colliding usernames for users with usernames and ids: %s",
users.stream().collect(Collectors.toMap(MapUserEntity::getUsername, MapUserEntity::getId))));
}
return entityToAdapterFunc(realm).apply(users.get(0));
}