Remove string comparaison using '=='

This commit is contained in:
Brendan Le Ny 2024-06-12 15:38:47 +02:00
parent 5c2b20d4e0
commit 208659d42e
2 changed files with 9 additions and 6 deletions

View file

@ -18,6 +18,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;
@ -211,7 +212,7 @@ public class UserAdapter extends Adapter<UserModel, User> {
sameEmailUser = session.users().getUserByEmail(realm, email);
}
if ((sameUsernameUser != null && sameEmailUser != null)
&& (sameUsernameUser.getId() != sameEmailUser.getId())) {
&& (!StringUtils.equals(sameUsernameUser.getId(), sameEmailUser.getId()))) {
logger.warnf("found 2 possible users for remote user %s %s", username, email);
return false;
}

View file

@ -1,5 +1,7 @@
package sh.libre.scim.jpa;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import java.util.Objects;
@ -69,11 +71,11 @@ public class ScimResourceId implements Serializable {
return false;
ScimResourceId o = (ScimResourceId) other;
// TODO
return (o.id == id &&
o.realmId == realmId &&
o.componentId == componentId &&
o.type == type &&
o.externalId == externalId);
return (StringUtils.equals(o.id, id) &&
StringUtils.equals(o.realmId, realmId) &&
StringUtils.equals(o.componentId, componentId) &&
StringUtils.equals(o.type, type) &&
StringUtils.equals(o.externalId, externalId));
}
@Override