unbridled-41 opened a new issue, #10995:
URL: https://github.com/apache/rocketmq/issues/10995

   ### Before Creating the Bug Report
   
   - [x] I found a test reliability/CI flaky issue, not a question.
   - [x] I searched existing GitHub Issues and found no obvious duplicate.
   - [x] The issue belongs to this repository.
   
   ### 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
   


-- 
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]

Reply via email to