Fix NPE when running a range query on a `scaled_float` with no upper bound. #20253
The null check was there, but on the wrong variable.
This commit is contained in:
parent
a0becd26b1
commit
34aaea641d
|
@ -244,7 +244,7 @@ public class ScaledFloatFieldMapper extends FieldMapper {
|
|||
lo = Math.round(Math.ceil(dValue * scalingFactor));
|
||||
}
|
||||
Long hi = null;
|
||||
if (lowerTerm != null) {
|
||||
if (upperTerm != null) {
|
||||
double dValue = NumberFieldMapper.NumberType.DOUBLE.parse(upperTerm).doubleValue();
|
||||
if (includeUpper == false) {
|
||||
dValue = Math.nextDown(dValue);
|
||||
|
|
|
@ -117,8 +117,8 @@ public class ScaledFloatFieldTypeTests extends FieldTypeTestCase {
|
|||
IndexSearcher searcher = newSearcher(reader);
|
||||
final int numQueries = 1000;
|
||||
for (int i = 0; i < numQueries; ++i) {
|
||||
double l = (randomDouble() * 2 - 1) * 10000;
|
||||
double u = (randomDouble() * 2 - 1) * 10000;
|
||||
Double l = randomBoolean() ? null : (randomDouble() * 2 - 1) * 10000;
|
||||
Double u = randomBoolean() ? null : (randomDouble() * 2 - 1) * 10000;
|
||||
boolean includeLower = randomBoolean();
|
||||
boolean includeUpper = randomBoolean();
|
||||
Query doubleQ = NumberFieldMapper.NumberType.DOUBLE.rangeQuery("double", l, u, includeLower, includeUpper);
|
||||
|
|
Loading…
Reference in New Issue