From de1357cbd199ded1790e696db7dc5c32934cadb8 Mon Sep 17 00:00:00 2001 From: Seongguk Jeong Date: Mon, 17 Jul 2023 22:15:41 +0900 Subject: [PATCH] Refactor equals method To use the accessor method for username instead of directly accessing the attribute. --- .../org/springframework/security/core/userdetails/User.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/springframework/security/core/userdetails/User.java b/core/src/main/java/org/springframework/security/core/userdetails/User.java index 141f65dde8..5d164bea76 100644 --- a/core/src/main/java/org/springframework/security/core/userdetails/User.java +++ b/core/src/main/java/org/springframework/security/core/userdetails/User.java @@ -179,8 +179,8 @@ public class User implements UserDetails, CredentialsContainer { */ @Override public boolean equals(Object obj) { - if (obj instanceof User) { - return this.username.equals(((User) obj).username); + if (obj instanceof User user) { + return this.username.equals(user.getUsername()); } return false; }