wangkangmao opened a new pull request, #11548:
URL: https://github.com/apache/rocketmq/pull/11548

   ## Summary
   
   Fixes #11532.
   
   `TopicMessageType.getMetricsValue()` calls `value.toLowerCase()` without a 
locale. Under a Turkish default locale, uppercase `I` is lowercased to dotless 
`ı` (`U+0131`), so the metrics label values `PRIORITY`, `FIFO`, `TRANSACTION`, 
`LITE`, `MIXED` become `prıorıty`, `fıfo`, `transactıon`, `lıte`, `mıxed`. 
These values feed `LABEL_MESSAGE_TYPE` in `SendMessageProcessor` (message count 
/ throughput / size metrics) and are reused by `ReplyMessageProcessor` / 
`ScheduleMessageService`, so metric dimensions change solely with the broker 
JVM locale, breaking cross-broker aggregation.
   
   ## Root cause
   
   
`common/src/main/java/org/apache/rocketmq/common/attribute/TopicMessageType.java:69-71`
 uses the locale-sensitive `String.toLowerCase()`. The repository already 
handles the identical class of problem elsewhere with a locale-neutral 
conversion: 
`common/src/main/java/org/apache/rocketmq/common/compression/CompressionType.java:54`
 uses `name.trim().toUpperCase(Locale.ROOT)`.
   
   ## Changes
   
   - `TopicMessageType.java`: import `java.util.Locale`; change 
`value.toLowerCase()` to `value.toLowerCase(Locale.ROOT)`.
   - `TopicMessageTypeTest.java`:
     - Make the existing `testGetMetricsValue` expectation locale-neutral 
(`toLowerCase(Locale.ROOT)`).
     - Add `testGetMetricsValueIsLocaleIndependent`, which sets the JVM default 
locale to `tr-TR`, asserts all eight enum values map to fixed ASCII-lowercase 
labels, and restores the original locale in a `finally` block.
   
   No production behavior changes except making the label conversion 
deterministic. Only the `common` module is touched.
   
   ## Verification
   
   Local toolchain: Apache Maven 3.9.9 (aliyun mirror), Eclipse Temurin JDK 17, 
module `common`, command:
   
   ```
   mvn -s settings-aliyun.xml -q -pl common -am -Dtest=TopicMessageTypeTest 
-DfailIfNoTests=false test
   ```
   
   - **Positive (patched code)**: `Tests run: 9, Failures: 0, Errors: 0, 
Skipped: 0` — all nine tests pass, including the new Turkish-locale regression.
   - **Negative control (reverted production code to `value.toLowerCase()`)**: 
`Tests run: 2, Failures: 1` with
     `org.junit.ComparisonFailure: expected:<unspec[ifi]ed> but 
was:<unspec[?f?]ed>` at the new test — the dotless-`ı` corruption described in 
the issue is reproduced exactly, confirming the test is a real regression guard 
for this bug.
   - Checkstyle (`maven-checkstyle-plugin` validate phase) passes on the 
patched code; `git diff --check` is clean.
   
   Baseline blobs were fetched from the upstream `develop` branch (production 
`9d3cb76`, test `1029e39`) and confirmed byte-identical to the local `develop` 
HEAD (`28960fd`), so this patch applies cleanly to current develop.
   


-- 
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]

Reply via email to