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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11532
   
   ### Brief Description
   
   `TopicMessageType.getMetricsValue()` called `value.toLowerCase()` with no 
`Locale`, so the returned metric label depended on the broker JVM's default 
locale. Under a Turkish locale (`tr-TR`), uppercase `I` lowercases to dotless 
`ı` (U+0131), so `FIFO`, `PRIORITY`, `LITE`, `MIXED`, `TRANSACTION` and 
`UNSPECIFIED` became `fıfo`, `prıorıty`, `lıte`, `mıxed`, `transactıon` and 
`unspecıfıed`. This value is used as the `LABEL_MESSAGE_TYPE` metric dimension 
in `SendMessageProcessor`, `ReplyMessageProcessor` and 
`ScheduleMessageService`, so the same broker fleet could report different 
metric dimensions depending only on JVM locale, breaking cross-broker 
aggregation and dashboard queries.
   
   This PR changes the call to `value.toLowerCase(Locale.ROOT)`, matching the 
existing precedent in `CompressionType.of`, which already uses `Locale.ROOT` 
for the same class of issue. It also adds 
`testGetMetricsValueUnderTurkishLocale`, which sets the default locale to 
`tr-TR` (restored in `finally`) and asserts every `getMetricsValue()` against 
hardcoded ASCII expectations. The existing `testGetMetricsValue` is 
locale-blind (it compares against the default-locale `toLowerCase()`), so it 
cannot catch this bug; the new test can.
   
   ### How Did You Test This Change?
   
   The new unit test was not executed locally: this environment has no access 
to Maven Central, so the repo test suite cannot run here. CI is the arbiter for 
the new test.
   
   What was verified locally with a plain JDK (Temurin 17, no dependencies):
   
   - A standalone harness reproducing the exact `toLowerCase()` vs 
`toLowerCase(Locale.ROOT)` behavior under `tr-TR` confirmed the bug: the old 
call returns dotless-ı forms for 6 of the 8 values (`FIFO` -> `fıfo`, code 
points U+0066 U+0131 U+0066 U+006F), while the `Locale.ROOT` call returns plain 
ASCII lowercase for all 8.
   - The same harness ran the new test's 8 hardcoded assertions against both 
implementations: the old implementation passes 2/8 (fail-before), the fixed 
implementation passes 8/8, and the default locale is restored afterwards.
   


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