LUCENE-7118: Move numDims check before modulo numDims

This commit is contained in:
Ryan Ernst 2016-03-20 13:49:33 -07:00
parent 54e662b6da
commit 7f9c4d886d
1 changed files with 3 additions and 3 deletions

View File

@ -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;