From df318a5c01ac037fad18bdfbbd2003377d18f046 Mon Sep 17 00:00:00 2001 From: Ulrik Sandberg Date: Thu, 13 Nov 2008 14:37:40 +0000 Subject: [PATCH] LDAP-151 DistinguishedName violates the equals()/hashCode() contract --- .../java/org/springframework/ldap/core/LdapRdnComponent.java | 2 +- .../org/springframework/ldap/core/DistinguishedNameTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java b/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java index 82a9d370..76398e0a 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java @@ -161,7 +161,7 @@ public class LdapRdnComponent implements Comparable, Serializable { * @see java.lang.Object#hashCode() */ public int hashCode() { - return key.hashCode() ^ value.hashCode(); + return key.toUpperCase().hashCode() ^ value.toUpperCase().hashCode(); } /* diff --git a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTest.java b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTest.java index aa3cb2ca..82ef0519 100644 --- a/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTest.java +++ b/core/src/test/java/org/springframework/ldap/core/DistinguishedNameTest.java @@ -140,8 +140,8 @@ public class DistinguishedNameTest extends TestCase { // original object final Object originalObject = new DistinguishedName("cn=john.doe, OU=Users,OU=Some company,C=SE"); - // another object that has the same values as the original - final Object identicalObject = new DistinguishedName("cn=john.doe, OU=Users,OU=Some company,C=SE"); + // another object that has the same values as the original (case is ignored) + final Object identicalObject = new DistinguishedName("cn=john.doe, OU=Users,OU=SOME COMPANY,C=SE"); // another object with different values final Object differentObject = new DistinguishedName("cn=john.doe, OU=Users,OU=Some other company,C=SE");