jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1387078 - /jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
Date Tue, 18 Sep 2012 10:09:23 GMT
Author: alexparvulescu
Date: Tue Sep 18 10:09:22 2012
New Revision: 1387078

URL: http://svn.apache.org/viewvc?rev=1387078&view=rev
Log:
JCR-3428 - NPE protection

Modified:
    jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java?rev=1387078&r1=1387077&r2=1387078&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DescendantSelfAxisQuery.java
Tue Sep 18 10:09:22 2012
@@ -471,9 +471,14 @@ class DescendantSelfAxisQuery extends Qu
             }
 
             collectContextHits();
-            currentDoc = subScorer.nextDoc();
             if (contextHits.isEmpty()) {
                 currentDoc = NO_MORE_DOCS;
+            } else {
+                if (subScorer != null) {
+                    currentDoc = subScorer.nextDoc();
+                } else {
+                    currentDoc = NO_MORE_DOCS;
+                }
             }
             while (currentDoc != NO_MORE_DOCS) {
                 if (isValid(currentDoc)) {
@@ -505,7 +510,9 @@ class DescendantSelfAxisQuery extends Qu
             // optimize in the case of an advance to finish.
             // see https://issues.apache.org/jira/browse/JCR-3082
             if (target == NO_MORE_DOCS) {
-                subScorer.advance(target);
+                if (subScorer != null) {
+                    subScorer.advance(target);
+                }
                 currentDoc = NO_MORE_DOCS;
                 return currentDoc;
             }
@@ -522,12 +529,14 @@ class DescendantSelfAxisQuery extends Qu
         private void collectContextHits() throws IOException {
             if (!contextHitsCalculated) {
                 long time = System.currentTimeMillis();
-                contextScorer.score(new AbstractHitCollector() {
-                    @Override
-                    protected void collect(int doc, float score) {
-                        contextHits.set(doc);
-                    }
-                }); // find all
+                if (contextScorer != null) {
+                    contextScorer.score(new AbstractHitCollector() {
+                        @Override
+                        protected void collect(int doc, float score) {
+                            contextHits.set(doc);
+                        }
+                    }); // find all
+                }
                 contextHitsCalculated = true;
                 time = System.currentTimeMillis() - time;
                 if (log.isDebugEnabled()) {



Mime
View raw message