zjncs opened a new pull request, #11075:
URL: https://github.com/apache/rocketmq/pull/11075
## Motivation
`GetColdDataFlowCtrInfoSubCommand.getAndPrint` pretty-prints the JSON
returned by the broker and passes it to `printf` **as the format string**:
```java
String formatStr = JSON.toJSONString(jsonObject,
JSONWriter.Feature.PrettyFormat);
System.out.printf(formatStr);
```
The payload is keyed by consumer group names, and `%` is a **legal
character** in consumer group and topic names — the validation regex is
`^[%|a-zA-Z0-9_-]+$` (it exists precisely to allow the `%RETRY%` /
`%RETRY%`-style prefixes). A group like `order%group` therefore makes the
command die halfway through the report:
```
java.util.MissingFormatArgumentException: Format specifier '%g'
```
(any `%` in the group name triggers `MissingFormatArgumentException`,
`UnknownFormatConversionException` or `UnknownFormatFlagsException` depending
on the following character — none of the command output is printed.)
## Modification
Print the payload literally:
```java
System.out.print(formatStr);
System.out.printf("%n");
```
## Verification
`mvn -pl tools test -Dtest=GetColdDataFlowCtrInfoSubCommandTest`
fail-before (fix reverted, test kept) — the mocked broker response contains
a legal group name `order%group`:
```
Tests run: 1, Failures: 0, Errors: 1
testPrintsEntriesWhoseGroupNameContainsPercent <<< ERROR!
java.util.MissingFormatArgumentException: Format specifier '%g'
```
pass-after:
```
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
```
and the captured stdout contains the untouched group name `order%group`.
No associated issue; found by code inspection.
--
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]