[ISSUE #10995] Stabilize client offline receipt handle test - #10996
[ISSUE #10995] Stabilize client offline receipt handle test#10996unbridled-41 wants to merge 1 commit into
Conversation
Signed-off-by: unbridled-41 <[email protected]>
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Test-only fix that stabilizes DefaultReceiptHandleManagerTest#testClientOffline by properly stubbing the async changeInvisibleTime() cleanup path and using Awaitility for the async assertion. Clean, minimal, and well-documented.
Correctness — The root cause is correctly identified: unstubbed changeInvisibleTime() returns null from Mockito, causing NPE in the async callback's whenComplete(). Stubbing with CompletableFuture.completedFuture(new AckResult()) ensures the cleanup path completes without error.
Tests — Awaitility usage is appropriate here. The 1-second timeout is reasonable since the stubbed future is already completed, so the wait should resolve nearly instantly. The Mockito.verify() inside untilAsserted correctly validates both the invocation and the final state.
Compatibility — No production code changes. Test-only scope matches the issue description exactly.
LGTM — no issues found.
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Brief Description
DefaultReceiptHandleManagerTest#testClientOfflinetriggers asynchronous receipt-handle cleanup afterCLIENT_UNREGISTER.The test previously did not stub
messagingProcessor.changeInvisibleTime()for the cleanup path. The unstubbed Mockito invocation returnsnull, and the asynchronousReturnHandleGroupWorkerThreadcan then throw aNullPointerExceptionwhen the test listener callswhenComplete().When this happens, the receipt handle is not removed and
returnHandleGroup()may insert the non-empty group back intoreceiptHandleGroupMap. Because the test immediately asserted that the map was empty after triggeringCLIENT_UNREGISTER, the assertion was timing-sensitive and could fail in Coverage CI.This change is test-only:
changeInvisibleTime()with a completedCompletableFuturefor the cleanup path;How Did You Test This Change?
Tested with JDK 8:
DefaultReceiptHandleManagerTest#testClientOffline: 50/50 repeated runs passedDefaultReceiptHandleManagerTest: 12/12 tests passedBUILD SUCCESSgit diff --check: passed