diff --git a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java index d798c2202b8..cfa644fea9b 100644 --- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java @@ -62,6 +62,9 @@ public abstract class PointRangeQuery extends Query { protected PointRangeQuery(String field, byte[] lowerPoint, byte[] upperPoint, int numDims) { checkArgs(field, lowerPoint, upperPoint); this.field = field; + if (numDims <= 0) { + throw new IllegalArgumentException("numDims must be positive, got " + numDims); + } if (lowerPoint.length == 0) { throw new IllegalArgumentException("lowerPoint has length of zero"); } @@ -71,9 +74,6 @@ public abstract class PointRangeQuery extends Query { if (lowerPoint.length != upperPoint.length) { throw new IllegalArgumentException("lowerPoint has length=" + numDims + " but upperPoint has different length=" + upperPoint.length); } - if (numDims <= 0) { - throw new IllegalArgumentException("numDims must be positive, got " + numDims); - } this.numDims = numDims; this.bytesPerDim = lowerPoint.length / numDims;