]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Fri, 23 Sep 2022 16:47:32 +0000 (18:47 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 23 Sep 2022 16:49:55 +0000 (18:49 +0200)
- e.g. lockUserAccount() changes userAccountStatus to LOCKED which results in
  Objects.equals() to return false even when it is the same user which causes
  an exception being thrown.
- checking the userId only won't be enough for an other use-case where a new
  user with same data is being created

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java

index 72b5b132860ff925199eabcc6c12d296a439b81f..da2ff87e57d496c532e15d0f4e88983ae0d8e74b 100644 (file)
@@ -151,8 +151,15 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS
 
                // Fetch whole list
                for (final User currentUser : this.fetchAllUsers()) {
-                       // Is found?
-                       if (Objects.equals(user, currentUser)) {
+                       /*
+                        * E.g. userAccountStatus can be fifferent because lockUserAccount
+                        * is setting it BEFORE this method is invoked. So this is enough
+                        * for us in this case. But otherwise e.g. when a new user is
+                        * created with same data, then this method must return FALSE even
+                        * when userId is currently NULL.
+                        */
+                       //* NOISY-DEBUG: */ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserExists: currentUser={1},currentUser.userId={2}", this.getClass(), currentUser, currentUser.getUserId())); //NOI18N
+                       if ((Objects.equals(user.getUserId(), currentUser.getUserId()) && user.getUserId() != null) || Objects.equals(user, currentUser)) {
                                // Yes, then set flag and exit iteration
                                isFound = true;
                                break;