Before Creating the Bug Report
Runtime platform environment
GitHub Actions Coverage workflow on a Linux runner.
RocketMQ version
Branch: develop. The failure was observed in the Coverage workflow.
JDK Version
JDK 8 (the Coverage workflow uses Java 8).
Describe the Bug
DefaultReceiptHandleManagerTest#testClientOffline is timing-sensitive during asynchronous cleanup.
After CLIENT_UNREGISTER calls clearGroup(), the group is removed from receiptHandleGroupMap synchronously. returnHandleGroup() then runs asynchronously on ReturnHandleGroupWorkerThread.
The test's StateEventListener calls messagingProcessor.changeInvisibleTime(...).whenComplete(...), but testClientOffline does not stub changeInvisibleTime() for this cleanup path. Mockito can therefore return null, causing a NullPointerException when the async worker calls whenComplete().
After that exception, the handle is not removed. When returnHandleGroup() sees that the group is still non-empty, it calls putIfAbsent() and can put the group back into receiptHandleGroupMap.
Meanwhile, the test immediately asserts receiptHandleManager.receiptHandleGroupMap.isEmpty() after triggering CLIENT_UNREGISTER. The final assertion therefore depends on async worker scheduling and can fail intermittently in Coverage CI.
This is a test reliability/flaky CI issue, not a production behavior report.
Steps to Reproduce
The failure was observed in the Coverage CI workflow. Run:
DefaultReceiptHandleManagerTest#testClientOffline
The problem is timing-sensitive, so a single local run does not guarantee reproduction. It was not claimed to reproduce consistently on an unmodified local checkout.
What Did You Expect to See?
testClientOffline should deterministically verify the asynchronous cleanup initiated by CLIENT_UNREGISTER, without failures caused by an unstubbed Mockito call or thread scheduling.
What Did You See Instead?
Coverage CI logged a NullPointerException in ReturnHandleGroupWorkerThread. The group could then be reinserted into the map, and the final isEmpty() assertion failed.
Additional Context
A test-only fix is prepared:
- Stub the cleanup-path
changeInvisibleTime() call with a completed CompletableFuture.
- Use Awaitility to wait for async cleanup completion.
- Do not use
Thread.sleep.
- Do not change production code.
Validation after the fix:
- JDK 8
testClientOffline: 50/50 passes
DefaultReceiptHandleManagerTest: 12/12 passes
- Proxy module: 308 tests run, 0 failures, 0 errors, 3 skipped;
BUILD SUCCESS
git diff --check passes
Before Creating the Bug Report
Runtime platform environment
GitHub Actions Coverage workflow on a Linux runner.
RocketMQ version
Branch:
develop. The failure was observed in the Coverage workflow.JDK Version
JDK 8 (the Coverage workflow uses Java 8).
Describe the Bug
DefaultReceiptHandleManagerTest#testClientOfflineis timing-sensitive during asynchronous cleanup.After
CLIENT_UNREGISTERcallsclearGroup(), the group is removed fromreceiptHandleGroupMapsynchronously.returnHandleGroup()then runs asynchronously onReturnHandleGroupWorkerThread.The test's
StateEventListenercallsmessagingProcessor.changeInvisibleTime(...).whenComplete(...), buttestClientOfflinedoes not stubchangeInvisibleTime()for this cleanup path. Mockito can therefore returnnull, causing aNullPointerExceptionwhen the async worker callswhenComplete().After that exception, the handle is not removed. When
returnHandleGroup()sees that the group is still non-empty, it callsputIfAbsent()and can put the group back intoreceiptHandleGroupMap.Meanwhile, the test immediately asserts
receiptHandleManager.receiptHandleGroupMap.isEmpty()after triggeringCLIENT_UNREGISTER. The final assertion therefore depends on async worker scheduling and can fail intermittently in Coverage CI.This is a test reliability/flaky CI issue, not a production behavior report.
Steps to Reproduce
The failure was observed in the Coverage CI workflow. Run:
The problem is timing-sensitive, so a single local run does not guarantee reproduction. It was not claimed to reproduce consistently on an unmodified local checkout.
What Did You Expect to See?
testClientOfflineshould deterministically verify the asynchronous cleanup initiated byCLIENT_UNREGISTER, without failures caused by an unstubbed Mockito call or thread scheduling.What Did You See Instead?
Coverage CI logged a
NullPointerExceptioninReturnHandleGroupWorkerThread. The group could then be reinserted into the map, and the finalisEmpty()assertion failed.Additional Context
A test-only fix is prepared:
changeInvisibleTime()call with a completedCompletableFuture.Thread.sleep.Validation after the fix:
testClientOffline: 50/50 passesDefaultReceiptHandleManagerTest: 12/12 passesBUILD SUCCESSgit diff --checkpasses