[Bug] BitsArray rejects partial-byte clones but accepts bit lengths beyond backing capacity
维护者通常 1 天内回复
评估
调研方向
The report identifies the BitsArray byte-array constructor and gives reproductions for cloning a 9-bit array and accepting a bit length beyond backing capacity. Start by locating BitsArray and its constructor, then inspect the existing tests for create(int) and byte-array construction. Done means valid partial-byte arrays clone with their logical length and independent storage, while lengths beyond capacity are rejected; linked pull request #11459 is already open.
由索引模型根据 Issue 内容生成。
描述
Before Creating the Bug Report
-
I found a bug, not just asking a question, which should be created in GitHub Discussions.
-
I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
-
I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
Windows 11, local utility reproducer and native Maven filter-module tests. No broker deployment or message-loss claim.
RocketMQ version
develop, revision 5.5.1, commit 57c2dc04f78cc7e73e6b8c9436ee0fff0d0f46c3. The current develop source still has the same constructor.
JDK Version
OpenJDK 1.8.0_302 (GraalVM CE 21.2.0); also reproduced with Java 21 using Java 8-targeted utility/test classes. Native Maven validation used Java 8 and Maven 3.6.3.
Describe the Bug
The byte-array constructor rejects bitLength < bytes.length * 8 instead of rejecting a logical length larger than the backing capacity. As a result, any positive non-byte-aligned array created by create(int) fails to clone, while an impossible byte-array capacity is accepted. The null/empty/non-positive checks and defensive copy are otherwise present.
Steps to Reproduce
BitsArray.create(9).clone();
// IllegalArgumentException: BitLength is less than bytes.length() * 8
BitsArray.create(new byte[] {1, 0}, 9);
// Same exception despite sufficient capacity.
BitsArray.create(new byte[] {1}, 9).getBit(8);
// Constructor accepts it; subsequent access is out of bounds.
What Did You Expect to See?
Cloning a valid 9-bit array preserves its logical length, contents and independent backing storage. A byte-array constructor accepts a logical bit length within storage capacity and rejects lengths beyond that capacity.
What Did You See Instead?
Valid partial-byte reconstruction and clone throw IllegalArgumentException. A one-byte backing array can be declared as nine bits, allowing a later ArrayIndexOutOfBoundsException.
Additional Context
Duplicate checks: #10506 (merged) and #8664 (closed) fix position bounds, not this constructor capacity comparison. No matching open BitsArray PR or discussion was found.
A minimal correction and regression tests are prepared. The updated utility class has 28 tests: 3 failed before the fix and all 28 passed after on Java 8/21. Native Java 8 filter reactor: 110 tests passed, 0 failures/errors/skips, with Checkstyle and SpotBugs passing. BloomFilter normally rounds to whole-byte lengths, so no live broker failure or message-loss claim is made.
AI assistance: OpenAI Codex was used for investigation, implementation and tests.
- 主要语言
- Java
- 星标
- 22.7k
- 派生
- 12k
- 平均合并
- 3 天 18 小时
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/rocketmq 的其他 Issue
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration可能已有人在做 @amalsaidov 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
CompressionType.of fails under the Turkish locale可能已有人在做 @sharanggupta 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
[rocketmq-client-python] TransactionMQProducer allocates an unused producer during initialization未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[Bug] notifyMasterOnline aborts the long-polling wake-up with a NullPointerException when an arrival drains a bucket first可能已有人在做 @iloveeyjafjalla 于 29 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
apache/rocketmq#11441 · 1 条评论 ·
维护者通常 1 天内回复
-
[Enhancement] FilterFactory duplicate-registration and unregister semantics lack tests可能已有人在做 @chennaji9 于 34 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
apache/rocketmq#11340 · 2 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
bug emitter:client:csharp
难度 2/5 1-3 小时 新手友好度 84/100
microsoft/typespec#12572 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)未关闭
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
area/ai area/backend component/zeebe kind/task
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
spAnser/reacharound#38 ·