Skip to content

Commit 42020b1

Browse files
authored
Prevent zero radius in BaseXYPointTestCase (#15315)
Fixes some spurious CI failures.
1 parent b85f030 commit 42020b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lucene/test-framework/src/java/org/apache/lucene/tests/geo/BaseXYPointTestCase.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,11 @@ protected void verifyRandomDistances(float[] xs, float[] ys) throws Exception {
920920
final float centerX = nextX();
921921
final float centerY = nextY();
922922

923-
// So the query can cover at most 50% of the cartesian space:
924-
final float radius = random().nextFloat() * Float.MAX_VALUE / 2;
923+
float radius = 0f;
924+
while (radius == 0f) {
925+
// So the query can cover at most 50% of the cartesian space:
926+
radius = random().nextFloat() * Float.MAX_VALUE / 2;
927+
}
925928

926929
if (VERBOSE) {
927930
final DecimalFormat df =
@@ -953,6 +956,7 @@ protected void verifyRandomDistances(float[] xs, float[] ys) throws Exception {
953956
}
954957

955958
if (hits.get(docID) != expected) {
959+
final float finalRadius = radius;
956960
Consumer<StringBuilder> explain =
957961
(b) -> {
958962
if (Double.isNaN(xs[id]) == false) {
@@ -964,7 +968,7 @@ protected void verifyRandomDistances(float[] xs, float[] ys) throws Exception {
964968
.append(" distance=")
965969
.append(distance)
966970
.append(" vs radius=")
967-
.append(radius);
971+
.append(finalRadius);
968972
}
969973
};
970974
buildError(docID, expected, id, xs, ys, query, liveDocs, explain);

0 commit comments

Comments
 (0)