use of org.neo4j.server.security.auth.exception.ConcurrentModificationException in project neo4j by neo4j.
the class AbstractUserRepository method update.
@Override
public void update(User existingUser, User updatedUser) throws ConcurrentModificationException, IOException, InvalidArgumentsException {
// Assert input is ok
if (!existingUser.name().equals(updatedUser.name())) {
throw new IllegalArgumentException("The attempt to update the role from '" + existingUser.name() + "' to '" + updatedUser.name() + "' failed. Changing a roles name is not allowed.");
}
synchronized (this) {
// Copy-on-write for the users list
List<User> newUsers = new ArrayList<>();
boolean foundUser = false;
for (User other : users) {
if (other.equals(existingUser)) {
foundUser = true;
newUsers.add(updatedUser);
} else {
newUsers.add(other);
}
}
if (!foundUser) {
throw new ConcurrentModificationException();
}
users = newUsers;
usersByName.put(updatedUser.name(), updatedUser);
persistUsers();
}
}
Aggregations