Skip to content

Commit

Permalink
fix: IndexOutOfBoundsException when process pop response (#7003)
Browse files Browse the repository at this point in the history
  • Loading branch information
redlsz authored Aug 15, 2023
1 parent ac411da commit 55e0cdb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,10 @@ private static Map<String, List<Long>> buildQueueOffsetSortedMap(String topic, L
Long.parseLong(messageExt.getProperty(MessageConst.PROPERTY_INNER_MULTI_QUEUE_OFFSET)));
continue;
}
key = ExtraInfoUtil.getStartOffsetInfoMapKey(messageExt.getTopic(), messageExt.getQueueId());
// Value of POP_CK is used to determine whether it is a pop retry,
// cause topic could be rewritten by broker.
key = ExtraInfoUtil.getStartOffsetInfoMapKey(messageExt.getTopic(),
messageExt.getProperty(MessageConst.PROPERTY_POP_CK), messageExt.getQueueId());
if (!sortMap.containsKey(key)) {
sortMap.put(key, new ArrayList<>(4));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ public CompletableFuture<PopResult> popMessage(ProxyContext ctx, AddressableMess
// <topicMark@queueId, msg queueOffset>
Map<String, List<Long>> sortMap = new HashMap<>(16);
for (MessageExt messageExt : messageExtList) {
String key = ExtraInfoUtil.getStartOffsetInfoMapKey(messageExt.getTopic(), messageExt.getQueueId());
// Value of POP_CK is used to determine whether it is a pop retry,
// cause topic could be rewritten by broker.
String key = ExtraInfoUtil.getStartOffsetInfoMapKey(messageExt.getTopic(),
messageExt.getProperty(MessageConst.PROPERTY_POP_CK), messageExt.getQueueId());
if (!sortMap.containsKey(key)) {
sortMap.put(key, new ArrayList<>(4));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ public static String getStartOffsetInfoMapKey(String topic, long key) {
return (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) ? RETRY_TOPIC : NORMAL_TOPIC) + "@" + key;
}

public static String getStartOffsetInfoMapKey(String topic, String popCk, long key) {
return ((topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) || popCk != null) ? RETRY_TOPIC : NORMAL_TOPIC) + "@" + key;
}

public static String getQueueOffsetKeyValueKey(long queueId, long queueOffset) {
return QUEUE_OFFSET + queueId + "%" + queueOffset;
}
Expand Down

0 comments on commit 55e0cdb

Please sign in to comment.