wang-jiahua opened a new pull request, #41:
URL: https://github.com/apache/rocketmq-a2a/pull/41
### Which Issue(s) This PR Fixes
Fixes #40
### Brief Description
`RocketMQUtil.getResult` only removed its `(msgId -> A2AResponseFuture)`
registration from the static `MESSAGE_RESPONSE_MAP` after `future.get(120s)`
returned normally. On `TimeoutException`, `ExecutionException`, or
`InterruptedException` the removal was skipped, and since the completion side
never removes and there is no sweeper, every timed-out or failed request leaked
one entry in a JVM-lifetime static map.
Fix: wrap the `get` in `try { ... } finally {
msgIdAndAsyncTypedMap.remove(responseMessageId); }` so every exit path cleans
up.
### How Did You Test This Change?
New deterministic test
`RocketMQUtilLeakTest#getResultShouldNotLeakPendingEntryWhenResponseFails`: a
background thread calls `getResult`, the main thread completes the future
exceptionally (seconds, no 120s wait) and asserts the map entry is gone. It
fails on the unfixed code ("pending future entry leaked in
MESSAGE_RESPONSE_MAP") and passes with the fix. 1/1 on current main.
--
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]