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

View file

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