Skip to content

Apache Lucene open-source search software

Fix TestLateInteractionField.testInputValidation (#14929)

Samuel.G1eeb66293170
diff --git a/lucene/core/src/test/org/apache/lucene/document/TestLateInteractionField.java b/lucene/core/src/test/org/apache/lucene/document/TestLateInteractionField.java
index 5adf59daf89..4e0b5701213 100644
--- a/lucene/core/src/test/org/apache/lucene/document/TestLateInteractionField.java
+++ b/lucene/core/src/test/org/apache/lucene/document/TestLateInteractionField.java
@@ -64,14 +64,16 @@ public class TestLateInteractionField extends LuceneTestCase {
expectThrows(IllegalArgumentException.class, () -> LateInteractionField.encode(emptyTokens));
final int dim = 128;
- float[][] value = new float[random().nextInt(3, 12)][];
- for (int i = 0; i < value.length; i++) {
+ final int numVectors = random().nextInt(3, 12);
+ float[][] value = new float[numVectors][];
+ for (int i = 0; i < numVectors - 1; i++) {
if (random().nextBoolean()) {
value[i] = TestVectorUtil.randomVector(dim);
} else {
value[i] = TestVectorUtil.randomVector(dim + 1);
}
}
+ value[numVectors - 1] = TestVectorUtil.randomVector(dim + 2);
expectThrows(IllegalArgumentException.class, () -> LateInteractionField.encode(value));
}