apache / apache/rocketmq-dashboard
[Bug] DashboardCollectTask.fetchBrokerRuntimeStats discards the retry result, making its retry logic ineffective
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 683
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 58
Description
### Describe the Bug
`DashboardCollectTask.fetchBrokerRuntimeStats(brokerAddr, retryTime)` retries on failure, but the retry is ineffective: the catch block calls `fetchBrokerRuntimeStats(brokerAddr, retryTime - 1)` **discarding the return value**, then unconditionally rethrows the original exception. Even when a retry succeeds, its result is thrown away and the caller still sees the original failure — the retries only add sleep time.
The existing test actually documents the broken behavior: `DashboardCollectTaskTest.testCollectBroker` stubs the fetch to "throw once, then return a kvTable" (clearly intending to exercise a successful retry), yet asserts that `collectBroker` throws.
### Steps to Reproduce
Stub `fetchBrokerRuntimeStats` to fail once then succeed (as the existing test does); `collectBroker` still fails with `RuntimeException: fetchBrokerRuntimeStats exception`.
### What Did You Expect to See?
A transient failure is absorbed by the retry and the collected stats are returned.
### What Did You See Instead?
The retry result is discarded and the original exception is rethrown unconditionally.
### Additional Context
Fix incoming: `return fetchBrokerRuntimeStats(brokerAddr, retryTime - 1);` in the catch block. When retries are exhausted the method already returns null at `retryTime == 0`, and the caller `collectBroker` already handles it with `if (kvTable == null) continue`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with DashboardCollectTask.fetchBrokerRuntimeStats and DashboardCollectTaskTest.testCollectBroker, which stubs one failure followed by a successful kvTable result. Verify that the retry's returned stats reach collectBroker and update the test expectation so it passes on transient recovery while preserving the retry-exhaustion behavior described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100