Skip to content

Commit

Permalink
Fix TestPostingsUtil#testIntegerOverflow failure. (#13979)
Browse files Browse the repository at this point in the history
The group vint logic is mistakenly using the long->int conversion logic for the
case when integers are being written rather than longs.

Closes #13978
  • Loading branch information
jpountz authored Nov 6, 2024
1 parent a888af7 commit 12ca477
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public static void writeGroupVInts(DataOutput out, byte[] scratch, int[] values,

// tail vints
for (; readPos < limit; readPos++) {
out.writeVInt(toInt(values[readPos]));
out.writeVInt(values[readPos]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ public class TestPostingsUtil extends LuceneTestCase {

// checks for bug described in https://github.com/apache/lucene/issues/13373
public 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];

Expand Down

0 comments on commit 12ca477

Please sign in to comment.