Repository navigation
Conversation
Apply namespaces to fresh queue objects for assign, pause and resume. A Topic change alters the MessageQueue hash code and makes the original key unfindable in the caller collection. Cover all three operations with a caller-owned HashSet and verify that the namespaced internal queue is assigned, paused or resumed.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #11616 +/- ##
=============================================
+ Coverage 50.47% 50.72% +0.25%
- Complexity 14711 14806 +95
=============================================
Files 1391 1391
Lines 103541 103587 +46
Branches 13575 13578 +3
=============================================
+ Hits 52261 52545 +284
+ Misses 45042 44788 -254
- Partials 6238 6254 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| @Override | ||
| public void assign(Collection<MessageQueue> messageQueues) { | ||
| defaultLitePullConsumerImpl.assign(queuesWithNamespace(messageQueues)); | ||
| defaultLitePullConsumerImpl.assign(wrapQueuesWithNamespace(messageQueues)); |
There was a problem hiding this comment.
With a namespace configured, reusing the same MessageQueue for assign() and commit(Map, ...) now silently skips the offset update because the assigned queue is namespaced but the commit key is not. Could we apply the same namespace conversion to the explicit commit APIs without mutating the caller's queues?
ShannonDing
left a comment
There was a problem hiding this comment.
The defensive copy fixes caller-owned queue mutation, but breaks explicit offset commits when the original MessageQueue is reused after assign: the caller’s topic remains orders, while the internal queue uses demo%orders.
Identical regression tests against the parent and PR head confirm:
| API | persist |
Parent 74c2a8e |
Head cf2946e |
|---|---|---|---|
commit(Map, boolean) |
true |
Pass | Fail |
commit(Set, boolean) |
true |
Pass | Fail |
commit(Set, boolean) |
false |
Pass | Fail |
commitSync(Map, boolean) |
true |
Pass | Fail |
commitSync(Map, boolean) |
false |
Pass | Fail |
All failing calls return normally. With an initial cached offset of 0 and a target offset of 1:
persist=false: the cached offset remains0.persist=true:persistAllremoves the namespaced cache entry (READ_FROM_MEMORY = -1), without invoking the broker-write boundary.
The Set tests initialize a valid internal consume offset. No-namespace and explicitly namespaced-queue controls pass on both revisions for both persist values. Tests execute real assignment/offset-store logic with mocked lifecycle, scheduling and network boundaries; no live broker was used.
Please retain the defensive copy and normalize copied Map keys/Set elements in all three explicit commit APIs, preserving caller collections and existing null/empty-input behavior. Please include regression coverage for both persist values.
Use namespaced queue copies for explicit Map and Set offset commits. Cover both persistence modes and preserve caller-owned inputs.
Install route and broker stubs before the client factory starts so the scheduled route refresh cannot race with Mockito setup. Use a fresh factory for each test and release the real transport before replacing it.
ShannonDing
left a comment
There was a problem hiding this comment.
已验证最新提交修复了上一轮指出的显式提交 namespace 回归:commit(Map, boolean)、commit(Set, boolean) 和 commitSync(Map, boolean) 均能正确处理复用的调用者队列,且不修改调用者对象或集合。
本地相关测试 62/62 通过。保留新增测试、仅将主代码换回首版提交 cf2946e67 后,三个 API × 两种 persist 模式的 6 个复用队列用例全部失败,确认新增测试能够覆盖上一轮问题;恢复最新代码后全部通过。验证使用真实 assignment 和 offset cache,网络边界为 mock。
当前 CI 全部通过,未发现新的阻塞问题,建议合并。LGTM。
Which Issue(s) This PR Fixes
Found during source review of
DefaultLitePullConsumer.Brief Description
With a namespace configured,
assign,pause, andresumechanged the Topic of caller-ownedMessageQueueobjects. Topic participates inhashCode, so a queue already stored in aHashSetcould become unfindable. Apply the namespace to queue copies before passing them to the consumer implementation.The explicit offset APIs now use the same queue namespace as assignment. Copy and normalize the keys for
commit(Map, boolean)andcommitSync(Map, boolean), and the elements forcommit(Set, boolean). This keeps the assigned queue, offset cache, and persistence keys aligned when the caller reuses the original queue. If a map contains both forms of the same queue, use the offset from its already namespaced key. Null and empty inputs follow the existing path.How Did You Test This Change?
assign,pause, andresumeregression tests verify that the original queue is still findable and each operation uses the namespaced queue internally.persistvalues. The six cases that reuse the original queue afterassign()fail oncf2946eand pass with the follow-up. The cached offset reaches1in each case. Whenpersistis true, the mock records one broker-write call fordemo%ordersat offset1. Controls cover already namespaced queues, no namespace, both forms of the same queue, and null and empty inputs.mvn -B -pl client -am \ -Dtest=DefaultLitePullConsumerExplicitCommitTest,DefaultLitePullConsumerTest,DefaultLitePullConsumerImplTest,ClientConfigTest \ -Dsurefire.failIfNoSpecifiedTests=false -Djacoco.skip=true test