Copilot commented on code in PR #10975:
URL: https://github.com/apache/rocketmq/pull/10975#discussion_r3870184453
##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/ExtraInfoUtil.java:
##########
@@ -216,18 +216,27 @@ public static Map<String, List<Long>>
parseMsgOffsetInfo(String msgOffsetInfo) {
}
for (String one : array) {
- String[] split = one.split(MessageConst.KEY_SEPARATOR);
- if (split.length != 3) {
+ long separators = locateEntrySeparators(one);
+ if (separators < 0) {
throw new IllegalArgumentException("parse msgOffsetMap error,
" + msgOffsetMap);
Review Comment:
The IllegalArgumentException for malformed msgOffsetInfo currently prints
the (likely empty) map rather than the offending input, which makes debugging
malformed extraInfo much harder. Use the original msgOffsetInfo string (or the
current entry) in the message, consistent with the other parse*Info methods.
##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/header/ExtraInfoUtil.java:
##########
@@ -274,20 +285,46 @@ public static Map<String, Integer>
parseOrderCountInfo(String orderCountInfo) {
}
for (String one : array) {
- String[] split = one.split(MessageConst.KEY_SEPARATOR);
- if (split.length != 3) {
+ long separators = locateEntrySeparators(one);
+ if (separators < 0) {
throw new IllegalArgumentException("parse orderCountInfo
error, " + orderCountInfo);
}
- String key = split[0] + "@" + split[1];
+ int sep1 = (int) (separators >>> 32);
+ int sep2 = (int) separators;
+ String key = buildEntryKey(one, sep1, sep2);
if (startOffsetMap.containsKey(key)) {
throw new IllegalArgumentException("parse orderCountInfo
error, duplicate, " + orderCountInfo);
}
- startOffsetMap.put(key, Integer.valueOf(split[2]));
+ startOffsetMap.put(key, Integer.valueOf(one.substring(sep2 + 1)));
}
return startOffsetMap;
}
+ /**
+ * Locates the two {@link MessageConst#KEY_SEPARATOR} positions of an
entry laid out as
+ * {@code retryFlag queueId value}, packed as {@code (sep1 << 32) | sep2}.
Returns a negative
+ * value when the entry does not have exactly three non-empty fields,
mirroring the previous
+ * split-based validation without allocating the intermediate array.
+ */
Review Comment:
The Javadoc says this helper "mirrors" the previous split-based validation,
but the implementation explicitly rejects empty fields (sep1/sep2 adjacency,
leading/trailing separators). Since this is a behavior change called out in the
PR description/tests, the comment should reflect the stricter validation to
avoid misleading future readers.
--
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]