directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1765410 - /directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
Date Tue, 18 Oct 2016 10:43:35 GMT
Author: elecharny
Date: Tue Oct 18 10:43:35 2016
New Revision: 1765410

URL: http://svn.apache.org/viewvc?rev=1765410&view=rev
Log:
Changed the way we compute the hashcode as we have an unordered set

Modified:
    directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java

Modified: directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java?rev=1765410&r1=1765409&r2=1765410&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
(original)
+++ directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
Tue Oct 18 10:43:35 2016
@@ -210,9 +210,19 @@ public abstract class UserClass
         {
             int result = 37;
 
+            // 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 ( Dn dn : this.names )
             {
-                result = result * 17 + dn.hashCode();
+                int h = dn.hashCode();
+                
+                if ( h != 0 )
+                {
+                    result = result * dn.hashCode();
+                }
             }
 
             return result;



Mime
View raw message