Skip to content

Commit

Permalink
apply review comments
Browse files Browse the repository at this point in the history
Signed-off-by: panguixin <panguixin@bytedance.com>
  • Loading branch information
bugmakerrrrrr committed Jul 29, 2024
1 parent 6777ca6 commit e33606f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,7 @@ public void testSortMissingNumbers() throws Exception {
SearchRequestBuilder searchRequestBuilder = client().prepareSearch()
.setQuery(matchAllQuery())
.addSort(SortBuilders.fieldSort("u_value").order(SortOrder.ASC).missing(randomBoolean() ? -1 : "-1"));
assertFailures(
searchRequestBuilder,
RestStatus.BAD_REQUEST,
containsString("missing value of type [unsigned_long] must not be negative")
);
assertFailures(searchRequestBuilder, RestStatus.BAD_REQUEST, containsString("Value [-1] is out of range for an unsigned long"));
}

public void testSortMissingNumbersMinMax() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,11 @@ public Object missingObject(Object missingValue, boolean reversed) {
return min ? Numbers.MIN_UNSIGNED_LONG_VALUE : Numbers.MAX_UNSIGNED_LONG_VALUE;
} else {
if (missingValue instanceof Number) {
long ul = ((Number) missingValue).longValue();
if (ul < 0) {
throw new IllegalArgumentException("missing value of type [unsigned_long] must not be negative");
}
return BigInteger.valueOf(ul);
return Numbers.toUnsignedLongExact((Number) missingValue);
} else {
BigInteger missing = new BigInteger(missingValue.toString());
if (missing.signum() < 0) {
throw new IllegalArgumentException("missing value of type [unsigned_long] must not be negative");
throw new IllegalArgumentException("Value [" + missingValue + "] is out of range for an unsigned long");
}
return missing;
}
Expand Down

0 comments on commit e33606f

Please sign in to comment.