From ec60f5c43cea32cc7531e582e335c9ed826f4b94 Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Fri, 25 Mar 2016 20:15:07 -0400 Subject: [PATCH] fix bug in exception's message --- .../org/apache/lucene/search/PointRangeQuery.java | 2 +- .../org/apache/lucene/search/TestPointQueries.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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 eb183e25840..4991096e7cf 100644 --- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java @@ -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; diff --git a/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java b/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java index c2136c4d663..bc9ef759a18 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java @@ -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()); + } }