Repository navigation
Conversation
Start the partial-byte print loop at remainder minus one, preserving logical width and bit order. Generated-by: OpenAI Codex
Cover exact logical width, a nonzero padding bit, bit order, byte-aligned arrays and empty output. Generated-by: OpenAI Codex
utafrali
left a comment
There was a problem hiding this comment.
The one-character fix (j = this.bitLength % Byte.SIZE - 1) correctly trims the extra padding bit from the most significant partial byte in BitsArray.toString(), preserves the byte-aligned and empty cases (the condition bitLength % Byte.SIZE > 0 keeps the branch inactive for aligned lengths), and the new BitsArrayRenderingTest covers logical width, non-zero padding, high-to-low ordering, and the aligned/empty paths. Minimal, well-scoped bug fix with good test coverage.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. The fix correctly addresses the off-by-one error in BitsArray.toString() rendering.
Summary
Fixed padding bit rendering in BitsArray.toString() for non-byte-aligned bit lengths.
Analysis
The original code started iteration at j = bitLength % Byte.SIZE, which rendered one extra bit. For a 7-bit array, it would render 8 bits instead of 7. The fix correctly adjusts to j = bitLength % Byte.SIZE - 1, ensuring only the logical number of bits are rendered.
The test coverage is comprehensive, covering various bit lengths (1, 7, 9, 10, 15, 17, 63, 65) and verifying bit ordering in partial bytes.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. Correct one-line fix — the most significant partial byte was starting at bitLength % 8, which included one padding bit outside the logical range. Starting at bitLength % 8 - 1 retains the exact logical width. The tests cover all edge cases: logical width across 8 non-byte-aligned lengths, padding exclusion, partial-byte bit order, byte-aligned arrays, and empty arrays. Three of the four tests failed before the correction, confirming the fix.
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Fixes #11462
Brief Description
The most significant partial byte starts rendering at bitLength % 8, which includes one padding bit outside the logical range. Start at remainder minus one to retain the exact logical width and high-to-low order. Byte-aligned and empty rendering are preserved.
This is independent of the constructor capacity change in #11459 and the earlier index checks in #10506.
How Did You Test This Change?
mvn -B -pl filter -am -Dtest=BitsArrayTest,BitsArrayRenderingTest,BloomFilterTest,ExpressionTest,FilterSpiTest,ParserTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false test.This is a utility rendering contract fix, with no asserted live broker message-loss trigger.
AI assistance: OpenAI Codex was used for investigation, implementation and tests; commits include tooling provenance.