From 35ebfd625f142d0d6bcfad34de774a11c06f273e Mon Sep 17 00:00:00 2001 From: "wangjiahua.wjh" Date: Wed, 10 Jun 2026 21:52:27 +0800 Subject: [PATCH 1/3] [ISSUE #10464] Avoid unnecessary allocation in Message.getProperty and NFE in getPriority - getProperty(): return null when properties map is uninitialized instead of creating an empty HashMap as a side-effect of a read-only call. - getPriority(): add null/empty fast-path before NumberUtils.toInt() to skip the NFE throw+catch when PRIORITY is unset (the common case). Co-Authored-By: Claude Opus 4.6 (1M context) --- .../rocketmq/common/message/Message.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/org/apache/rocketmq/common/message/Message.java b/common/src/main/java/org/apache/rocketmq/common/message/Message.java index b64f3520c16..821754d9dec 100644 --- a/common/src/main/java/org/apache/rocketmq/common/message/Message.java +++ b/common/src/main/java/org/apache/rocketmq/common/message/Message.java @@ -102,11 +102,21 @@ public String getUserProperty(final String name) { return this.getProperty(name); } + /** + * Returns the value of the named property, or {@code null} if the property is not set + * or the properties map has not been initialized. + *

+ * Note: this method is read-only and does not lazily initialize the internal + * properties map. To add properties, use {@link #putProperty(String, String)} which + * creates the map on demand. + * + * @param name the property key + * @return the property value, or {@code null} + */ public String getProperty(final String name) { if (null == this.properties) { - this.properties = new HashMap<>(); + return null; } - return this.properties.get(name); } @@ -164,7 +174,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); } public boolean isWaitStoreMsgOK() { From 21b3f37c92eb5c06aef34f2e3f041cab39ae9e73 Mon Sep 17 00:00:00 2001 From: "wangjiahua.wjh" Date: Mon, 15 Jun 2026 16:59:52 +0800 Subject: [PATCH 2/3] chore: retrigger CI From f7b1200af01b2f7de42ccf8658ccd41dc7a8cf8a Mon Sep 17 00:00:00 2001 From: "wangjiahua.wjh" Date: Mon, 15 Jun 2026 17:49:32 +0800 Subject: [PATCH 3/3] chore: retrigger CI (flaky test)