Skip to content

Commit de1357c

Browse files
limvikjzheaux
authored andcommitted
Refactor equals method
To use the accessor method for username instead of directly accessing the attribute.
1 parent ea19f82 commit de1357c

File tree

1 file changed

+2
-2
lines changed
  • core/src/main/java/org/springframework/security/core/userdetails

1 file changed

+2
-2
lines changed

core/src/main/java/org/springframework/security/core/userdetails/User.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ private static SortedSet<GrantedAuthority> sortAuthorities(Collection<? extends
179179
*/
180180
@Override
181181
public boolean equals(Object obj) {
182-
if (obj instanceof User) {
183-
return this.username.equals(((User) obj).username);
182+
if (obj instanceof User user) {
183+
return this.username.equals(user.getUsername());
184184
}
185185
return false;
186186
}

0 commit comments

Comments
 (0)