directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1765412 - /directory/shared/branches/shared-value/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/UserClass.java
Date Tue, 18 Oct 2016 10:45:43 GMT
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;



Mime
View raw message