You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2016/05/03 04:39:40 UTC

lucene-solr:master: LUCENE-7262: Fix NPE, this should lazy-init in start()

Repository: lucene-solr
Updated Branches:
  refs/heads/master 70bcd562f -> 91153b962


LUCENE-7262: Fix NPE, this should lazy-init in start()


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/91153b96
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/91153b96
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/91153b96

Branch: refs/heads/master
Commit: 91153b9627d7bd9e17dcb4762ebbaf26bc3410f4
Parents: 70bcd56
Author: David Smiley <ds...@apache.org>
Authored: Mon May 2 22:39:32 2016 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Mon May 2 22:39:32 2016 -0400

----------------------------------------------------------------------
 .../spatial/composite/IntersectsRPTVerifyQuery.java      | 11 ++++++-----
 .../lucene/spatial/prefix/AbstractPrefixTreeQuery.java   |  4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/91153b96/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java
index 886491e..ebb3ada 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/composite/IntersectsRPTVerifyQuery.java
@@ -19,9 +19,6 @@ package org.apache.lucene.spatial.composite;
 import java.io.IOException;
 import java.util.Map;
 
-import org.locationtech.spatial4j.shape.Shape;
-import org.locationtech.spatial4j.shape.SpatialRelation;
-
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.queries.function.FunctionValues;
 import org.apache.lucene.queries.function.ValueSource;
@@ -38,6 +35,8 @@ import org.apache.lucene.spatial.prefix.AbstractVisitingPrefixTreeQuery;
 import org.apache.lucene.spatial.prefix.tree.Cell;
 import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
 import org.apache.lucene.util.DocIdSetBuilder;
+import org.locationtech.spatial4j.shape.Shape;
+import org.locationtech.spatial4j.shape.SpatialRelation;
 
 /**
  * A spatial Intersects predicate that distinguishes an approximated match from an exact match based on which cells
@@ -163,8 +162,8 @@ public class IntersectsRPTVerifyQuery extends Query {
     // TODO consider if IntersectsPrefixTreeQuery should simply do this and provide both sets
 
     class IntersectsDifferentiatingVisitor extends VisitorTemplate {
-      DocIdSetBuilder approxBuilder = new DocIdSetBuilder(maxDoc, terms);
-      DocIdSetBuilder exactBuilder = new DocIdSetBuilder(maxDoc, terms);
+      DocIdSetBuilder approxBuilder;
+      DocIdSetBuilder exactBuilder;
       boolean approxIsEmpty = true;
       boolean exactIsEmpty = true;
       DocIdSet exactDocIdSet;
@@ -176,6 +175,8 @@ public class IntersectsRPTVerifyQuery extends Query {
 
       @Override
       protected void start() throws IOException {
+        approxBuilder = new DocIdSetBuilder(maxDoc, terms);
+        exactBuilder = new DocIdSetBuilder(maxDoc, terms);
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/91153b96/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java
index 11cc22c..e599e79 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/AbstractPrefixTreeQuery.java
@@ -18,7 +18,6 @@ package org.apache.lucene.spatial.prefix;
 
 import java.io.IOException;
 
-import org.locationtech.spatial4j.shape.Shape;
 import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.PostingsEnum;
@@ -35,6 +34,7 @@ import org.apache.lucene.search.Weight;
 import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
 import org.apache.lucene.util.BitSet;
 import org.apache.lucene.util.DocIdSetBuilder;
+import org.locationtech.spatial4j.shape.Shape;
 
 /**
  * Base class for Lucene Queries on SpatialPrefixTree fields.
@@ -105,7 +105,7 @@ public abstract class AbstractPrefixTreeQuery extends Query {
     protected final LeafReaderContext context;
     protected final int maxDoc;
 
-    protected final Terms terms;
+    protected final Terms terms; // maybe null
     protected final TermsEnum termsEnum;//remember to check for null!
     protected PostingsEnum postingsEnum;