You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/10/18 10:45:43 UTC
svn commit: r1765412 -
/directory/shared/branches/shared-value/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
Author: elecharny
Date: Tue Oct 18 10:45:43 2016
New Revision: 1765412
URL: http://svn.apache.org/viewvc?rev=1765412&view=rev
Log:
Changed the way we compute the hashcode as we have an unordered set
Modified:
directory/shared/branches/shared-value/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
Modified: directory/shared/branches/shared-value/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java?rev=1765412&r1=1765411&r2=1765412&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java (original)
+++ directory/shared/branches/shared-value/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java Tue Oct 18 10:45:43 2016
@@ -209,9 +209,19 @@ public abstract class UserClass
{
int result = 37;
- for ( String dn : this.names )
+ // Use a slightly different hashcode here : we multiple
+ // each DN in the set with the result to have a result that
+ // is not dependent on the DN order in the Set.
+ // In order to avoid result of 0 if one of the DN hashcode,
+ // we discard them.
+ for ( String dn : names )
{
- result = result * 17 + dn.hashCode();
+ int h = dn.hashCode();
+
+ if ( h != 0 )
+ {
+ result = result * h;
+ }
}
return result;