[ISSUE #995] Harden cluster page against null component lists for real clusters - #1036
Conversation
|
Hello maintainers! This is my first pull request to this repo, so the CI workflow needs approval to run. @Aias00 @zhaohai could you please approve the workflow run for this PR? All tests pass locally (backend |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM — defensive improvement with proper error handling and test coverage.
Automated review by github-manager-bot
|
This PR has conflicts with the base branch and cannot be merged. Please rebase or merge the base branch into your branch and resolve the conflicts: git fetch origin
git checkout fix/cluster-null-safety-995
git rebase origin/rocketmq-studio
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
dd4c635 to
f2497a9
Compare
What is the purpose of the change
When a real RocketMQ cluster (configured via
STUDIO_ROCKETMQ_NAMESRV_ADDR) is described byRealClusterProviderand no proxy is provisioned, the producedClusterVOleavesproxies,tpsHistoryandconfigasnull. The cluster page dereferences them directly (c.proxies.length,cluster.config, summary counts), so a null payload throws aTypeErrorand the page goes blank.This PR makes the payload safe on both sides:
RealClusterProvidernow defaults a live cluster's absent runtime collections to empty —proxies/tpsHistoryasList.of(),configas an emptyClusterConfigVO— so the API never serializes JSONnullfor these component lists.brokers/proxies/nameServers/configaccess in the cluster page is guarded with?? []/?? {}, and the summary counts are extracted into a purecountClusterComponentshelper with unit tests.Brief changelog
server/.../cluster/broker/RealClusterProvider.java: defaultconfigandtpsHistoryto safe empty values (proxies already defaulted toList.of()).web/src/pages/cluster/index.tsx: null-safe access tobrokers,proxies,nameServers,selectedProxy.proxies,cluster.config; usecountClusterComponents.web/src/pages/cluster/clusterStats.ts(new): pure summary-count helper with empty-collection fallbacks.web/src/pages/cluster/clusterStats.test.ts(new): unit tests for empty, mixed and null component lists.server/.../cluster/broker/RealClusterProviderTest.java: new test asserting non-nullproxies/tpsHistory/configfor a live cluster without a proxy.Verifying this change
mvn test -Dtest=RealClusterProviderTest— 4 tests pass (3 existing + 1 new).npm test(vitest run) — 391 tests pass, including the newclusterStats.test.ts.eslint src/pages/cluster— no errors.Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyleto make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.Closes #995