This is an automated email from the ASF dual-hosted git repository.
duhengforever 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 50ba523 [ISSUE #1699] Fix wrong topic max length in TopicValidator
(#1700)
50ba523 is described below
commit 50ba523bab3a1ea66f98f1b1ab3b46463df14949
Author: rongtong <[email protected]>
AuthorDate: Tue Jan 7 20:13:26 2020 +0800
[ISSUE #1699] Fix wrong topic max length in TopicValidator (#1700)
* fix(topicValidator):fix topic max length to 127
* test(topicValidator):modify relate tests
---
.../main/java/org/apache/rocketmq/broker/topic/TopicValidator.java | 6 +++---
.../java/org/apache/rocketmq/broker/topic/TopicValidatorTest.java | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git
a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicValidator.java
b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicValidator.java
index 8b53476..58b1cc8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicValidator.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicValidator.java
@@ -27,7 +27,7 @@ public class TopicValidator {
private static final String VALID_PATTERN_STR = "^[%|a-zA-Z0-9_-]+$";
private static final Pattern PATTERN = Pattern.compile(VALID_PATTERN_STR);
- private static final int CHARACTER_MAX_LENGTH = 255;
+ private static final int TOPIC_MAX_LENGTH = 127;
private static boolean regularExpressionMatcher(String origin, Pattern
pattern) {
if (pattern == null) {
@@ -51,9 +51,9 @@ public class TopicValidator {
return false;
}
- if (topic.length() > CHARACTER_MAX_LENGTH) {
+ if (topic.length() > TOPIC_MAX_LENGTH) {
response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("The specified topic is longer than topic max
length 255.");
+ response.setRemark("The specified topic is longer than topic max
length.");
return false;
}
diff --git
a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicValidatorTest.java
b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicValidatorTest.java
index 267931f..78be63f 100644
---
a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicValidatorTest.java
+++
b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicValidatorTest.java
@@ -47,10 +47,10 @@ public class TopicValidatorTest {
assertThat(response.getRemark()).contains("The specified topic is
conflict with AUTO_CREATE_TOPIC_KEY_TOPIC.");
clearResponse(response);
- res = TopicValidator.validateTopic(generateString(255), response);
+ res = TopicValidator.validateTopic(generateString(128), response);
assertThat(res).isFalse();
assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR);
- assertThat(response.getRemark()).contains("The specified topic is
longer than topic max length 255.");
+ assertThat(response.getRemark()).contains("The specified topic is
longer than topic max length.");
}