wang-jiahua commented on code in PR #10975:
URL: https://github.com/apache/rocketmq/pull/10975#discussion_r3877217391


##########
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:
   Agreed — both throw sites now include the original `msgOffsetInfo` string 
instead of the partially-built map (commit da87233).



##########
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:
   Reworded the Javadoc to state explicitly that this is stricter than the 
split-based validation and that corrupt entries are rejected with the same 
IllegalArgumentException the callers already throw (commit da87233).



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