-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes gh-12533
- Loading branch information
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,7 +329,7 @@ public static final class UserBuilder { | |
|
||
private String password; | ||
|
||
private List<GrantedAuthority> authorities; | ||
private List<GrantedAuthority> authorities = new ArrayList<>(); | ||
|
||
private boolean accountExpired; | ||
|
||
|
@@ -427,6 +427,7 @@ public UserBuilder roles(String... roles) { | |
* @see #roles(String...) | ||
*/ | ||
public UserBuilder authorities(GrantedAuthority... authorities) { | ||
Assert.notNull(authorities, "authorities cannot be null"); | ||
return authorities(Arrays.asList(authorities)); | ||
} | ||
|
||
|
@@ -439,7 +440,8 @@ public UserBuilder authorities(GrantedAuthority... authorities) { | |
* @see #roles(String...) | ||
*/ | ||
public UserBuilder authorities(Collection<? extends GrantedAuthority> authorities) { | ||
this.authorities = new ArrayList<>(authorities); | ||
Assert.notNull(authorities, "authorities cannot be null"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sjohnr
Member
|
||
this.authorities.addAll(authorities); | ||
return this; | ||
} | ||
|
||
|
@@ -452,6 +454,7 @@ public UserBuilder authorities(Collection<? extends GrantedAuthority> authoritie | |
* @see #roles(String...) | ||
*/ | ||
public UserBuilder authorities(String... authorities) { | ||
Assert.notNull(authorities, "authorities cannot be null"); | ||
return authorities(AuthorityUtils.createAuthorityList(authorities)); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Broken backwards compatibility. There is currently no way to reset the
this.authorities
list.For example, the code will not work correctly,
it will always merge new and old authorities, but the previous version will overwrite them
To solve this problem and return the past behavior, it is enough to call
this.authorities.clear();