fix bug in exception's message

This commit is contained in:
Mike McCandless 2016-03-25 20:15:07 -04:00
parent 585683d6a7
commit ec60f5c43c
2 changed files with 14 additions and 1 deletions

View File

@ -72,7 +72,7 @@ public abstract class PointRangeQuery extends Query {
throw new IllegalArgumentException("lowerPoint is not a fixed multiple of numDims");
}
if (lowerPoint.length != upperPoint.length) {
throw new IllegalArgumentException("lowerPoint has length=" + numDims + " but upperPoint has different length=" + upperPoint.length);
throw new IllegalArgumentException("lowerPoint has length=" + lowerPoint.length + " but upperPoint has different length=" + upperPoint.length);
}
this.numDims = numDims;
this.bytesPerDim = lowerPoint.length / numDims;

View File

@ -2012,4 +2012,17 @@ public class TestPointQueries extends LuceneTestCase {
other[2] = (byte) 5;
assertFalse(q1.equals(BinaryPoint.newSetQuery("a", new byte[][] {zeros, other})));
}
public void testInvalidPointLength() {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> {
new PointRangeQuery("field", new byte[4], new byte[8], 1) {
@Override
protected String toString(int dimension, byte[] value) {
return "foo";
}
};
});
assertEquals("lowerPoint has length=4 but upperPoint has different length=8", e.getMessage());
}
}