Apache Lucene open-source search software
Fix TestPostingsUtil#testIntegerOverflow failure. (#13979)
Adrien Grand12ca4779b962
diff --git a/lucene/core/src/java/org/apache/lucene/util/GroupVIntUtil.java b/lucene/core/src/java/org/apache/lucene/util/GroupVIntUtil.javaindex 949292fd9d2..e95e2eee4db 100644--- a/lucene/core/src/java/org/apache/lucene/util/GroupVIntUtil.java+++ b/lucene/core/src/java/org/apache/lucene/util/GroupVIntUtil.java@@ -292,7 +292,7 @@ public final class GroupVIntUtil {// tail vintsfor (; readPos < limit; readPos++) {- out.writeVInt(toInt(values[readPos]));+ out.writeVInt(values[readPos]);}}}diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene101/TestPostingsUtil.java b/lucene/core/src/test/org/apache/lucene/codecs/lucene101/TestPostingsUtil.javaindex 41bb5c01f07..5d02d0561e3 100644--- a/lucene/core/src/test/org/apache/lucene/codecs/lucene101/TestPostingsUtil.java+++ b/lucene/core/src/test/org/apache/lucene/codecs/lucene101/TestPostingsUtil.java@@ -27,7 +27,15 @@ public class TestPostingsUtil extends LuceneTestCase {// checks for bug described in https://github.com/apache/lucene/issues/13373public void testIntegerOverflow() throws IOException {- final int size = random().nextInt(1, ForUtil.BLOCK_SIZE);+ // Size that writes the first value as a regular vint+ int randomSize1 = random().nextInt(1, 3);+ // Size that writes the first value as a group vint+ int randomSize2 = random().nextInt(4, ForUtil.BLOCK_SIZE);+ doTestIntegerOverflow(randomSize1);+ doTestIntegerOverflow(randomSize2);+ }++ private void doTestIntegerOverflow(int size) throws IOException {final int[] docDeltaBuffer = new int[size];final int[] freqBuffer = new int[size];