directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1769371 - in /directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem: AbstractAttributeTypeProtectedItem.java MaxValueCountElem.java
Date Sat, 12 Nov 2016 05:07:50 GMT
Author: elecharny
Date: Sat Nov 12 05:07:50 2016
New Revision: 1769371

URL: http://svn.apache.org/viewvc?rev=1769371&view=rev
Log:
Protected the code against potential NPE

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

Modified: directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java?rev=1769371&r1=1769370&r2=1769371&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java
(original)
+++ directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java
Sat Nov 12 05:07:50 2016
@@ -104,7 +104,20 @@ public abstract class AbstractAttributeT
             
             if ( attributeTypes != null )
             {
-                return attributeTypes.equals( that.attributeTypes );
+                if ( ( that.attributeTypes == null ) || ( that.attributeTypes.size() != attributeTypes.size()
) )
+                {
+                    return false;
+                }
+                
+                for ( AttributeType attributeType : attributeTypes )
+                {
+                    if ( !that.attributeTypes.contains( attributeType ) )
+                    {
+                        return false;
+                    }
+                }
+                
+                return true;
             }
             else
             {

Modified: directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java?rev=1769371&r1=1769370&r2=1769371&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java
(original)
+++ directory/shared/trunk/ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/protectedItem/MaxValueCountElem.java
Sat Nov 12 05:07:50 2016
@@ -80,7 +80,11 @@ public class MaxValueCountElem
     {
         int hash = 37;
         hash = hash * 17 + maxCount;
-        hash = hash * 17 + attributeType.hashCode();
+        
+        if ( attributeType != null )
+        {
+            hash = hash * 17 + attributeType.hashCode();
+        }
         
         return hash;
     }
@@ -124,6 +128,22 @@ public class MaxValueCountElem
     @Override
     public String toString()
     {
-        return "{ type " + attributeType.getName() + ", maxCount " + maxCount + " }";
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( "{ type " );
+        
+        if ( attributeType != null )
+        {
+            sb.append( attributeType.getName() );
+        }
+        else
+        {
+            sb.append( "null" );
+        }
+        
+        sb.append( ", maxCount " ).append( maxCount );
+        sb.append( "}" );
+        
+        return sb.toString();
     }
 }



Mime
View raw message