You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 09:53:52 UTC
[lucene] 38/45: SOLR-15219: Fix TestPointFields integer overflow
(#2460)
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 29d02bab80bd61d4e1b1f03dd0a22c0de02948e8
Author: David Smiley <ds...@salesforce.com>
AuthorDate: Fri Mar 5 13:42:13 2021 -0500
SOLR-15219: Fix TestPointFields integer overflow (#2460)
And also restore it's getRandomInts(..,..,bound) semantics to what it was -- positive or negative random values.
(cherry picked from commit f36a867bd07270421b8295f1698adf45c4905149)
---
.../src/test/org/apache/solr/schema/TestPointFields.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index aa096fc..b185a13 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -364,7 +364,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
int bucketNum = 0;
int minBucketVal = min;
for (PosVal<Integer> value : sortedValues) {
- while (value.val - minBucketVal >= gap) {
+ while ((long)value.val - (long)minBucketVal >= gap) {
++bucketNum;
minBucketVal += gap;
}
@@ -2215,17 +2215,20 @@ public class TestPointFields extends SolrTestCaseJ4 {
});
}
- private List<Integer> getRandomInts(int length, boolean missingVals, int bound) {
- return getRandomList(length, missingVals, () -> random().nextInt() % bound);
+ private List<Integer> getRandomInts(int length, boolean missingVals, int boundPosNeg) {
+ assert boundPosNeg > 0L;
+ return getRandomList(length, missingVals,
+ () -> (random().nextBoolean() ? 1 : -1) * random().nextInt(boundPosNeg));
}
private List<Integer> getRandomInts(int length, boolean missingVals) {
return getRandomList(length, missingVals, () -> random().nextInt());
}
- private List<Long> getRandomLongs(int length, boolean missingVals, long bound) {
- assert bound > 0L;
- return getRandomList(length, missingVals, () -> random().nextLong() % bound); // see Random.nextInt(int bound)
+ private List<Long> getRandomLongs(int length, boolean missingVals, long boundPosNeg) {
+ assert boundPosNeg > 0L;
+ return getRandomList(length, missingVals,
+ () -> random().nextLong() % boundPosNeg); // see Random.nextInt(int bound)
}
private List<Long> getRandomLongs(int length, boolean missingVals) {