directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1546397 - in /directory: apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/ apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/ apacheds/trunk/xdbm-partiti...
Date Thu, 28 Nov 2013 16:57:15 GMT
Author: kayyagari
Date: Thu Nov 28 16:57:14 2013
New Revision: 1546397

URL: http://svn.apache.org/r1546397
Log:
o fixed a NPE when an expression node contains zero count (DIRSERVER-1922)
o added a test to verify the fix

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EmptyEvaluator.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java?rev=1546397&r1=1546396&r2=1546397&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
Thu Nov 28 16:57:14 2013
@@ -63,6 +63,7 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.annotations.LoadSchema;
+import org.apache.directory.server.core.api.LdapCoreSessionConnection;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.integ.IntegrationUtils;
@@ -2027,4 +2028,27 @@ public class SearchIT extends AbstractLd
 
         assertNotNull( rootDse );
     }
+    
+    
+    /**
+     * Test for DIRSERVER-1922
+     */
+    @Test
+    public void testNotEvaluator() throws Exception
+    {
+        LdapConnection con = new LdapCoreSessionConnection( service.getAdminSession() );
+
+        EntryCursor cursor = con.search( "ou=groups,ou=system", "(!(gidNumber=00001))", SearchScope.ONELEVEL,
SchemaConstants.ALL_ATTRIBUTES_ARRAY );
+
+        int count = 0;
+        while ( cursor.next() )
+        {
+            count++;
+        }
+        
+        cursor.close();
+        
+        assertEquals( 5, count );
+    }
+    
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EmptyEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EmptyEvaluator.java?rev=1546397&r1=1546396&r2=1546397&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EmptyEvaluator.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EmptyEvaluator.java
Thu Nov 28 16:57:14 2013
@@ -24,7 +24,6 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.filter.UndefinedNode;
 import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Evaluator;
 
 
@@ -35,17 +34,12 @@ import org.apache.directory.server.xdbm.
  */
 public class EmptyEvaluator implements Evaluator<UndefinedNode>
 {
-    /** The backend */
-    private final Store db;
-
-
     /**
      * Create a new instance of the PassThroughEvaluator
      * @throws Exception
      */
-    public EmptyEvaluator( Store db )
+    public EmptyEvaluator()
     {
-        this.db = db;
     }
 
 
@@ -74,7 +68,7 @@ public class EmptyEvaluator implements E
      */
     public UndefinedNode getExpression()
     {
-        return null;
+        return UndefinedNode.UNDEFINED_NODE;
     }
 
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1546397&r1=1546396&r2=1546397&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
Thu Nov 28 16:57:14 2013
@@ -47,6 +47,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.search.PartitionSearchResult;
 import org.apache.directory.server.xdbm.search.SearchEngine;
 import org.apache.directory.server.xdbm.search.evaluator.BaseLevelScopeEvaluator;
+import org.apache.directory.server.xdbm.search.evaluator.EmptyEvaluator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -185,7 +186,7 @@ public class DefaultSearchEngine impleme
                 evaluator = evaluatorBuilder.build( filter );
 
                 // Special case if the filter selects no candidate
-                if ( evaluator == null )
+                if ( ( evaluator == null ) || ( evaluator instanceof EmptyEvaluator ) )
                 {
                     ScopeNode node = new ScopeNode( aliasDerefMode, effectiveBase, effectiveBaseId,
scope );
                     evaluator = new BaseLevelScopeEvaluator<Entry>( db, node );

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java?rev=1546397&r1=1546396&r2=1546397&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
Thu Nov 28 16:57:14 2013
@@ -43,6 +43,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.server.xdbm.search.evaluator.AndEvaluator;
 import org.apache.directory.server.xdbm.search.evaluator.ApproximateEvaluator;
+import org.apache.directory.server.xdbm.search.evaluator.EmptyEvaluator;
 import org.apache.directory.server.xdbm.search.evaluator.EqualityEvaluator;
 import org.apache.directory.server.xdbm.search.evaluator.GreaterEqEvaluator;
 import org.apache.directory.server.xdbm.search.evaluator.LessEqEvaluator;
@@ -64,6 +65,7 @@ public class EvaluatorBuilder
     private final Store db;
     private final SchemaManager schemaManager;
 
+    private static final EmptyEvaluator emptyEvaluator = new EmptyEvaluator();
 
     /**
      * Creates a top level Evaluator where leaves are delegated to a leaf node
@@ -86,7 +88,7 @@ public class EvaluatorBuilder
 
         if ( ( count != null ) && ( ( Long ) count == 0L ) )
         {
-            return null;
+            return emptyEvaluator;
         }
 
         switch ( node.getAssertionType() )
@@ -154,7 +156,7 @@ public class EvaluatorBuilder
         switch ( size )
         {
             case 0:
-                return null;
+                return emptyEvaluator;
 
             case 1:
                 return evaluators.get( 0 );
@@ -175,7 +177,7 @@ public class EvaluatorBuilder
         switch ( size )
         {
             case 0:
-                return null;
+                return emptyEvaluator;
 
             case 1:
                 return evaluators.get( 0 );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java?rev=1546397&r1=1546396&r2=1546397&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/filter/UndefinedNode.java
Thu Nov 28 16:57:14 2013
@@ -29,7 +29,7 @@ package org.apache.directory.api.ldap.mo
 public final class UndefinedNode extends AbstractExprNode
 {
     /** A static instance of this node */
-    public static final ExprNode UNDEFINED_NODE = new UndefinedNode();
+    public static final UndefinedNode UNDEFINED_NODE = new UndefinedNode();
 
 
     /**



Mime
View raw message