Skip to content

fix(tools): report unknown cluster as error in exportMetrics command - #11145

Open
zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/export-metrics-cluster-npe
Open

zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/export-metrics-cluster-npe

Conversation

@zjncs

@zjncs zjncs commented Sep 11, 2026

Copy link
Copy Markdown

Motivation

A typo in the required -c option of mqadmin exportMetrics made clusterAddrTable.get(clusterName) return null, and the following for-each threw a raw NullPointerException from inside the command, producing a stack trace instead of an error message.

Modifications

Print a cluster not exist error like the sibling cluster commands do.

Verification

Fail-before (new test, run against the unpatched code):

ExportMetricsCommandTest#testUnknownClusterReportsCleanError
java.lang.NullPointerException: Cannot invoke "java.util.Set.iterator()" because "brokerNameSet" is null

Pass-after:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 -- ExportMetricsCommandTest

A typo in the required -c option made clusterAddrTable.get(clusterName)
return null and the for-each threw a raw NullPointerException. Print a
'cluster not exist' error like the sibling cluster commands do.
Copilot AI lite review requested due to automatic review settings September 11, 2026 07:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Add null check for brokerNameSet in exportMetrics when the requested cluster does not exist, printing a clear error message instead of NPE.

LGTM — defensive null guard with test.


Automated review by github-manager-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants