wang-jiahua commented on code in PR #10468:
URL: https://github.com/apache/rocketmq/pull/10468#discussion_r3389201526
##########
common/src/main/java/org/apache/rocketmq/common/message/Message.java:
##########
@@ -164,7 +163,11 @@ public void setPriority(int priority) {
}
public int getPriority() {
- return
NumberUtils.toInt(this.getProperty(MessageConst.PROPERTY_PRIORITY), -1);
+ String value = this.getProperty(MessageConst.PROPERTY_PRIORITY);
+ if (value == null || value.isEmpty()) {
+ return -1;
+ }
+ return NumberUtils.toInt(value, -1);
Review Comment:
The early return is intentional and is the whole point of this fix.
`NumberUtils.toInt(null, -1)` internally calls `Integer.parseInt(null)` which
throws a `NumberFormatException`, catches it, and returns the default. This
throw+catch happens on every message because PRIORITY is almost never set. JFR
shows ~16,000 NFE/min from this path — each one allocates a stack trace. The
null/empty guard eliminates these exceptions entirely while preserving the same
return value.
--
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]