RockteMQ-AI commented on issue #11458:
URL: https://github.com/apache/rocketmq/issues/11458#issuecomment-6287443369
**Issue Evaluation**
Category: `type/bug` | Status: **Confirmed**
The reported issue has been verified against the current codebase on the
`develop` branch.
**Root Cause:** In the `BitsArray(byte[], int)` constructor (line 62), the
capacity check condition is inverted: `if (bitLength < bytes.length *
Byte.SIZE)` throws `IllegalArgumentException`. This rejects valid cases where
the logical bit length is within capacity, while accepting impossible cases
where it exceeds capacity.
**Impact:** `filter` module — `BitsArray.create(9).clone()` fails because `9
< 16` triggers the inverted check. Meanwhile `BitsArray.create(new byte[]{1},
9)` is accepted despite 9 bits exceeding 1-byte capacity, risking later
`ArrayIndexOutOfBoundsException`.
**Severity:** Low-Medium — utility constructor, affects BloomFilter and any
code cloning partial-byte `BitsArray` instances. No broker message-path impact
since BloomFilter normally uses byte-aligned lengths.
**Verified reproduction:**
- `BitsArray.create(9).clone()` → `IllegalArgumentException: BitLength is
less than bytes.length() * 8`
- `BitsArray.create(new byte[]{1}, 9).getBit(8)` → accepted but out of bounds
Changing `<` to `>` on line 62 resolves this. An automated fix proposal may
be generated. Reply `/approve` to proceed with PR generation.
---
*Automated evaluation by RockteMQ-AI*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]