jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1357591 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
Date Thu, 05 Jul 2012 13:14:57 GMT
Author: alexparvulescu
Date: Thu Jul  5 13:14:56 2012
New Revision: 1357591

URL: http://svn.apache.org/viewvc?rev=1357591&view=rev
Log:
JCR-3337 Negated descendant node query with no results throws NPE

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java?rev=1357591&r1=1357590&r2=1357591&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NotQuery.java
Thu Jul  5 13:14:56 2012
@@ -139,6 +139,12 @@ class NotQuery extends Query {
         public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder,
                 boolean topScorer) throws IOException {
             contextScorer = context.weight(searcher).scorer(reader, scoreDocsInOrder, topScorer);
+            if (contextScorer == null) {
+                // context query does not match any node
+                // the inverse is to match all nodes
+                return new MatchAllDocsQuery().createWeight(searcher).scorer(
+                        reader, scoreDocsInOrder, topScorer);
+            }
             return new NotQueryScorer(reader);
         }
 
@@ -185,10 +191,6 @@ class NotQuery extends Query {
             if (docNo == NO_MORE_DOCS) {
                 return docNo;
             }
-            if (contextScorer == null) {
-                docNo = NO_MORE_DOCS;
-                return docNo;
-            }
 
             if (docNo == -1) {
                 // get first doc of context scorer
@@ -229,10 +231,6 @@ class NotQuery extends Query {
             if (docNo == NO_MORE_DOCS) {
                 return docNo;
             }
-            if (contextScorer == null) {
-                docNo = NO_MORE_DOCS;
-                return docNo;
-            }
 
             // optimize in the case of an advance to finish.
             // see https://issues.apache.org/jira/browse/JCR-3091

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java?rev=1357591&r1=1357590&r2=1357591&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ChildAxisQueryTest.java
Thu Jul  5 13:14:56 2012
@@ -253,6 +253,6 @@ public class ChildAxisQueryTest extends 
                 + testRootNode.getPath()
                 + "') and not isdescendantnode(a,'"
                 + foo.getPath() + "')";
-        executeSQL2Query(sql, new Node[] {});
+        executeSQL2Query(sql, new Node[] {foo});
     }
 }



Mime
View raw message