Skip to content

fix(tools): reject clusterSendMsgRT amount below two instead of printing NaN - #11134

Open
zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/cluster-send-rt-amount-guard
Open

zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/cluster-send-rt-amount-guard

Conversation

@zjncs

@zjncs zjncs commented Sep 11, 2026

Copy link
Copy Markdown

Motivation

mqadmin clusterSendMsgRT -a 1 cannot measure anything: the only send is the warm-up sample, elapsed stays 0, and the RT is computed as 0/0 = NaN. In tlog mode new BigDecimal(NaN) then throws NumberFormatException on the very first round, aborting the whole monitoring command.

Modifications

Reject an amount below two up front with a clear usage message, since at least two messages are required for a measured RT.

Verification

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

ClusterSendMsgRTCommandTest#testAmountBelowTwoIsRejected
java.lang.AssertionError: ClusterSendMsgRTCommand command failed ; Infinite or NaN
(warm-up-only run computed RT = 0/0 = NaN and BigDecimal rejected it on the first round)

Pass-after:

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

…ing NaN

With -a 1 the only send is the warm-up sample, elapsed stays 0 and the
RT is computed as 0/0 = NaN; in tlog mode new BigDecimal(NaN) then throws
NumberFormatException on the very first round, aborting the monitoring
command. Reject the amount up front with a clear usage message since a
single message cannot produce a measured RT.
Copilot AI lite review requested due to automatic review settings September 11, 2026 07:12

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.

LGTM. Good defensive fix — rejecting amount < 2 up front prevents the NaN/NumberFormatException that would otherwise abort the monitoring command. Clear error message explains why.


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