// 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;