You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Have a field of type javax.naming.ldap.LdapName in your class.
2. Run EqualsVerifier.forClass([YourClass].class).verify()
What is the code (equals method, hashCode method, relevant fields) that
triggers the problem?
import javax.naming.ldap.LdapName;
public final class Foo {
private LdapName dn;
public Foo() {
}
public LdapName getDn() {
return dn;
}
public void setDn(LdapName dn) {
this.dn = dn;
}
@Override
public int hashCode() {
return dn.hashCode();
}
public boolean equals(Object other) {
if (other instanceof Foo) {
Foo f = (Foo) other;
return dn == f.dn || dn.equals(f.dn);
} else {
return false;
}
}
}
What error message does EqualsVerifier give?
ClassCastException: java.lang.String cannot be cast to javax.naming.ldap.Rdn
What did you expect?
Verify should work perfectly with no problems.
What version of EqualsVerifier are you using?
1.5
Please provide any additional information below.
LdapName's own equals() implementation doesn't defer equals() to the underlying
lists it's holding. It walks through the lists:
// Compare RDNs one by one for equality
for (int i = 0; i < rdns.size(); i++) {
// Compare a single pair of RDNs.
Rdn rdn1 = rdns.get(i);
Rdn rdn2 = that.rdns.get(i);
if (!rdn1.equals(rdn2)) {
return false;
}
}
The ClassCastException is caused by this line from the above:
Rdn rdn1 = rdns.get(i);
Original issue reported on code.google.com by [email protected] on 28 Nov 2014 at 2:20
Hi Julius,
Thanks for the very detailed issue report -- it makes it so much easier for me
to figure out what's going on :).
The issue you report is actually a known problem: see Issue 84 (specifically,
comment #7 and further). Unfortunately, I don't have a good solution for this
issue yet.
However, there is a workaround. You can add instances of LdapName to the prefab
values using EqualsVerifier's withPrefabValues method.
Regards,
Jan
Original issue reported on code.google.com by
[email protected]
on 28 Nov 2014 at 2:20The text was updated successfully, but these errors were encountered: