jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1352053 - 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 Wed, 20 Jun 2012 12:16:27 GMT
Author: alexparvulescu
Date: Wed Jun 20 12:16:26 2012
New Revision: 1352053

URL: http://svn.apache.org/viewvc?rev=1352053&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=1352053&r1=1352052&r2=1352053&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
Wed Jun 20 12:16:26 2012
@@ -185,6 +185,10 @@ 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
@@ -225,6 +229,10 @@ 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=1352053&r1=1352052&r2=1352053&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
Wed Jun 20 12:16:26 2012
@@ -243,4 +243,16 @@ public class ChildAxisQueryTest extends 
         executeSQLQuery(sql, new Node[] {foo});
     }
 
+    /**
+     * JCR-3337
+     */
+    public void testNotIsDescendantNodeQuery() throws Exception {
+        Node foo = testRootNode.addNode("foo");
+        testRootNode.getSession().save();
+        String sql = "SELECT a.* FROM [nt:base] as a WHERE isdescendantnode(a,'"
+                + testRootNode.getPath()
+                + "') and not isdescendantnode(a,'"
+                + foo.getPath() + "')";
+        executeSQL2Query(sql, new Node[] {});
+    }
 }



Mime
View raw message