Repository navigation
Conversation
Reject logical lengths beyond backing storage and allow valid partial-byte arrays. Regression coverage follows in this branch. Generated-by: OpenAI Codex
Correct two inverted capacity expectations and cover independent clone storage across nine bit lengths. Generated-by: OpenAI Codex
RockteMQ-AI
approved these changes
Oct 20, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
LGTM. This is a critical bug fix — the original validation was inverted.
Summary
Fixed the backing capacity validation in BitsArray constructor: the comparison direction was reversed, rejecting valid inputs and accepting invalid ones.
Analysis
Original bug:
if (bitLength < bytes.length * Byte.SIZE) { // WRONG: rejects valid cases
throw new IllegalArgumentException(...);
}This rejected valid cases (e.g., 10-bit array backed by 2 bytes) and accepted invalid cases (e.g., 20-bit array backed by 1 byte).
Fix:
if (bitLength > (long) bytes.length * Byte.SIZE) { // CORRECT
throw new IllegalArgumentException(...);
}The fix also adds (long) cast to prevent integer overflow for large byte arrays.
The updated tests correctly verify both valid and invalid cases. The clone test ensures independent storage and partial byte length preservation.
Automated review by github-manager-bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which Issue(s) This PR Fixes
Fixes #11458
Brief Description
Correct the reversed capacity comparison in the byte-array constructor. Valid partial-byte arrays can be reconstructed and cloned, while logical bit lengths beyond the backing storage are rejected. Use a long capacity calculation and retain the existing null/empty/non-positive checks and defensive copying.
Update two tests that encoded the reversed capacity expectations and add one clone regression covering nine bit lengths, retained contents, independent storage and logical bounds. This is separate from the index-bound changes in #10506.
How Did You Test This Change?
mvn -B -pl filter -am -Dtest=BitsArrayTest,BloomFilterTest,ExpressionTest,FilterSpiTest,ParserTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false testNo live broker or message-loss reproduction is claimed; BloomFilter normally rounds to whole bytes.
AI assistance: OpenAI Codex was used for investigation, implementation and tests; commit messages include tooling provenance.