wang-jiahua opened a new pull request, #10468: URL: https://github.com/apache/rocketmq/pull/10468
### Which Issue(s) This PR Fixes Fixes #10464 ### Brief Description Two per-message allocation/CPU fixes in `Message.java`: 1. **`getProperty(String)`**: when `properties == null`, returns `null` immediately instead of creating a `new HashMap<>()` as a side-effect of a read-only call. 2. **`getPriority()`**: adds a null/empty fast-path before delegating to `NumberUtils.toInt()`. Previously, `NumberUtils.toInt(null, -1)` internally called `Integer.parseInt(null)` which throws and catches a `NumberFormatException` on every invocation (~16,000 NFE/min under benchmark load). The fast-path skips this throw+catch when `PRIORITY` is unset (the vast majority of messages). #### Compatibility - `getProperty()` no longer creates an empty HashMap as a side-effect. Callers that relied on this side-effect to later `put` directly into `properties` (without going through `putProperty()`) would break — but no such callers exist in the codebase (verified by grep). - `getPriority()` return values are unchanged for all inputs. ### How Did You Test This Change ```bash mvn -pl common -Dcheckstyle.skip=false -Dspotbugs.skip=true validate # 0 Checkstyle violations ``` Existing unit tests pass. The behavioral change in `getProperty()` is safe because `hasProperty()` already handles `properties == null` by returning `false`, and all write paths go through `putProperty()` which creates the HashMap on demand. -- 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]
