提交 f4599a47 编写于 作者: 如梦技术's avatar 如梦技术 🐛

🐛 重构 topic 匹配规则,修复 gitee #I56BTC

上级 69e0bcf0
......@@ -36,6 +36,7 @@ public final class TopicUtil {
int topicFilterLength = topicFilterChars.length;
int topicNameLength = topicNameChars.length;
int topicFilterIdxEnd = topicFilterLength - 1;
int topicNameIdxEnd = topicNameLength - 1;
char ch;
// 是否进入 + 号层级通配符
boolean inLayerWildcard = false;
......@@ -73,7 +74,7 @@ public final class TopicUtil {
}
}
// topicName 长度不够了
if (topicNameLength < i) {
if (topicNameIdxEnd < i) {
return false;
}
// 进入通配符
......
......@@ -42,8 +42,8 @@ public class TopicUtilTest {
Assert.assertTrue(TopicUtil.match("#", "/iot/test"));
Assert.assertTrue(TopicUtil.match("/iot/test/#", "/iot/test"));
Assert.assertTrue(TopicUtil.match("/iot/test/#", "/iot/test"));
Assert.assertTrue(TopicUtil.match("/iot/test/#", "/iot/test/"));
Assert.assertTrue(TopicUtil.match("/iot/test/#", "/iot/test/1"));
Assert.assertTrue(TopicUtil.match("/iot/test/#", "/iot/test/123123/12312"));
Assert.assertTrue(TopicUtil.match("/iot/test/123", "/iot/test/123"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册