diff --git a/src/java/org/apache/lucene/search/NumericRangeQuery.java b/src/java/org/apache/lucene/search/NumericRangeQuery.java index d7355c041f3..8b4958ca332 100644 --- a/src/java/org/apache/lucene/search/NumericRangeQuery.java +++ b/src/java/org/apache/lucene/search/NumericRangeQuery.java @@ -127,6 +127,8 @@ public final class NumericRangeQuery extends MultiTermQuery { Number min, Number max, final boolean minInclusive, final boolean maxInclusive ) { assert (valSize == 32 || valSize == 64); + if (min == null && max == null) + throw new IllegalArgumentException("At least one value must be non-null"); if (precisionStep < 1 || precisionStep > valSize) throw new IllegalArgumentException("precisionStep may only be 1.."+valSize); this.field = field.intern(); diff --git a/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java index 444b87a0a46..ff7e3b91942 100644 --- a/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java +++ b/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java @@ -385,7 +385,6 @@ public class TestNumericRangeQuery32 extends LuceneTestCase { QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test4", 4, new Integer(10), new Integer(20), false, false)); QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test5", 4, new Integer(10), null, true, true)); QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test6", 4, null, new Integer(20), true, true)); - QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test7", 4, null, null, true, true)); QueryUtils.checkEqual( NumericRangeQuery.newIntRange("test8", 4, new Integer(10), new Integer(20), true, true), NumericRangeQuery.newIntRange("test8", 4, new Integer(10), new Integer(20), true, true) diff --git a/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java index 4be7d4b9661..9178556a6f6 100644 --- a/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java +++ b/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java @@ -385,7 +385,6 @@ public class TestNumericRangeQuery64 extends LuceneTestCase { QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test4", 4, new Long(10L), new Long(20L), false, false)); QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test5", 4, new Long(10L), null, true, true)); QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test6", 4, null, new Long(20L), true, true)); - QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test7", 4, null, null, true, true)); QueryUtils.checkEqual( NumericRangeQuery.newLongRange("test8", 4, new Long(10L), new Long(20L), true, true), NumericRangeQuery.newLongRange("test8", 4, new Long(10L), new Long(20L), true, true)