Copilot commented on code in PR #10468:
URL: https://github.com/apache/rocketmq/pull/10468#discussion_r3388995550


##########
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:
   `NumberUtils.toInt(value, -1)` already returns `-1` for `null` and 
non-parsable inputs (including empty strings). The explicit `null || isEmpty()` 
branch is redundant and adds extra control flow; consider simplifying to a 
single `return NumberUtils.toInt(this.getProperty(...), -1);` unless the 
early-return is intentionally required for readability/consistency.



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