This is an automated email from the ASF dual-hosted git repository.

zhouxzhan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 8e585d8767 [ISSUE #7543] Use "+" as the new separator for retry topic  
(#7655)
8e585d8767 is described below

commit 8e585d8767bc24ab21217498daaea12d76cfd8ca
Author: Zhouxiang Zhan <zhouxz...@apache.org>
AuthorDate: Fri Dec 15 16:08:43 2023 +0800

    [ISSUE #7543] Use "+" as the new separator for retry topic  (#7655)
---
 .../java/org/apache/rocketmq/common/KeyBuilder.java    | 11 ++++++-----
 .../org/apache/rocketmq/common/KeyBuilderTest.java     | 18 ++++++++----------
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/common/src/main/java/org/apache/rocketmq/common/KeyBuilder.java 
b/common/src/main/java/org/apache/rocketmq/common/KeyBuilder.java
index f2a8c40895..0f77c96ab0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/KeyBuilder.java
+++ b/common/src/main/java/org/apache/rocketmq/common/KeyBuilder.java
@@ -18,8 +18,9 @@ package org.apache.rocketmq.common;
 
 public class KeyBuilder {
     public static final int POP_ORDER_REVIVE_QUEUE = 999;
-    private static final String POP_RETRY_SEPARATOR_V1 = "_";
-    private static final String POP_RETRY_SEPARATOR_V2 = ":";
+    private static final char POP_RETRY_SEPARATOR_V1 = '_';
+    private static final char POP_RETRY_SEPARATOR_V2 = '+';
+    private static final String POP_RETRY_REGEX_SEPARATOR_V2 = "\\+";
 
     public static String buildPopRetryTopic(String topic, String cid) {
         return MixAll.RETRY_GROUP_TOPIC_PREFIX + cid + POP_RETRY_SEPARATOR_V2 
+ topic;
@@ -42,7 +43,7 @@ public class KeyBuilder {
 
     public static String parseNormalTopic(String retryTopic) {
         if (isPopRetryTopicV2(retryTopic)) {
-            String[] result = retryTopic.split(POP_RETRY_SEPARATOR_V2);
+            String[] result = retryTopic.split(POP_RETRY_REGEX_SEPARATOR_V2);
             if (result.length == 2) {
                 return result[1];
             }
@@ -52,7 +53,7 @@ public class KeyBuilder {
 
     public static String parseGroup(String retryTopic) {
         if (isPopRetryTopicV2(retryTopic)) {
-            String[] result = retryTopic.split(POP_RETRY_SEPARATOR_V2);
+            String[] result = retryTopic.split(POP_RETRY_REGEX_SEPARATOR_V2);
             if (result.length == 2) {
                 return 
result[0].substring(MixAll.RETRY_GROUP_TOPIC_PREFIX.length());
             }
@@ -65,6 +66,6 @@ public class KeyBuilder {
     }
 
     public static boolean isPopRetryTopicV2(String retryTopic) {
-        return retryTopic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) && 
retryTopic.contains(POP_RETRY_SEPARATOR_V2);
+        return retryTopic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) && 
retryTopic.contains(String.valueOf(POP_RETRY_SEPARATOR_V2));
     }
 }
diff --git 
a/common/src/test/java/org/apache/rocketmq/common/KeyBuilderTest.java 
b/common/src/test/java/org/apache/rocketmq/common/KeyBuilderTest.java
index f83e0aa143..3c75871eaf 100644
--- a/common/src/test/java/org/apache/rocketmq/common/KeyBuilderTest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/KeyBuilderTest.java
@@ -26,37 +26,35 @@ public class KeyBuilderTest {
     String group = "test-group";
 
     @Test
-    public void buildPopRetryTopic() {
-        assertThat(KeyBuilder.buildPopRetryTopic(topic, 
group)).isEqualTo(MixAll.RETRY_GROUP_TOPIC_PREFIX + group + ":" + topic);
+    public void testBuildPopRetryTopic() {
+        assertThat(KeyBuilder.buildPopRetryTopic(topic, 
group)).isEqualTo(MixAll.RETRY_GROUP_TOPIC_PREFIX + group + "+" + topic);
     }
 
     @Test
-    public void buildPopRetryTopicV1() {
+    public void testBuildPopRetryTopicV1() {
         assertThat(KeyBuilder.buildPopRetryTopicV1(topic, 
group)).isEqualTo(MixAll.RETRY_GROUP_TOPIC_PREFIX + group + "_" + topic);
     }
 
     @Test
-    public void parseNormalTopic() {
+    public void testParseNormalTopic() {
         String popRetryTopic = KeyBuilder.buildPopRetryTopic(topic, group);
         assertThat(KeyBuilder.parseNormalTopic(popRetryTopic, 
group)).isEqualTo(topic);
+
         String popRetryTopicV1 = KeyBuilder.buildPopRetryTopicV1(topic, group);
         assertThat(KeyBuilder.parseNormalTopic(popRetryTopicV1, 
group)).isEqualTo(topic);
-    }
 
-    @Test
-    public void testParseNormalTopic() {
-        String popRetryTopic = KeyBuilder.buildPopRetryTopic(topic, group);
+        popRetryTopic = KeyBuilder.buildPopRetryTopic(topic, group);
         
assertThat(KeyBuilder.parseNormalTopic(popRetryTopic)).isEqualTo(topic);
     }
 
     @Test
-    public void parseGroup() {
+    public void testParseGroup() {
         String popRetryTopic = KeyBuilder.buildPopRetryTopic(topic, group);
         assertThat(KeyBuilder.parseGroup(popRetryTopic)).isEqualTo(group);
     }
 
     @Test
-    public void isPopRetryTopicV2() {
+    public void testIsPopRetryTopicV2() {
         String popRetryTopic = KeyBuilder.buildPopRetryTopic(topic, group);
         
assertThat(KeyBuilder.isPopRetryTopicV2(popRetryTopic)).isEqualTo(true);
         String popRetryTopicV1 = KeyBuilder.buildPopRetryTopicV1(topic, group);

Reply via email to