From 77563c2c150942828e70209820f1dfc6db131e54 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 2 Dec 2021 09:53:09 -0500 Subject: [PATCH] LUCENE-10278: don't write zero-sized array in this test (#501) DocIdsWriter is not prepared for this. --- .../test/org/apache/lucene/util/bkd/TestDocIdsWriter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java index 247329461c3..d2115c8721f 100644 --- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java +++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java @@ -35,7 +35,7 @@ public class TestDocIdsWriter extends LuceneTestCase { int numIters = atLeast(100); try (Directory dir = newDirectory()) { for (int iter = 0; iter < numIters; ++iter) { - int[] docIDs = new int[random().nextInt(5000)]; + int[] docIDs = new int[1 + random().nextInt(5000)]; final int bpv = TestUtil.nextInt(random(), 1, 32); for (int i = 0; i < docIDs.length; ++i) { docIDs[i] = TestUtil.nextInt(random(), 0, (1 << bpv) - 1); @@ -49,7 +49,7 @@ public class TestDocIdsWriter extends LuceneTestCase { int numIters = atLeast(100); try (Directory dir = newDirectory()) { for (int iter = 0; iter < numIters; ++iter) { - int[] docIDs = new int[random().nextInt(5000)]; + int[] docIDs = new int[1 + random().nextInt(5000)]; final int bpv = TestUtil.nextInt(random(), 1, 32); for (int i = 0; i < docIDs.length; ++i) { docIDs[i] = TestUtil.nextInt(random(), 0, (1 << bpv) - 1); @@ -64,7 +64,7 @@ public class TestDocIdsWriter extends LuceneTestCase { int numIters = atLeast(100); try (Directory dir = newDirectory()) { for (int iter = 0; iter < numIters; ++iter) { - int size = random().nextInt(5000); + int size = 1 + random().nextInt(5000); Set set = new HashSet<>(size); int small = random().nextInt(1000); while (set.size() < size) {