From 1ec21de8f413a93e8a396dc625578a7a90d70051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BB=B6?= <1060026287@qq.com> Date: Fri, 26 Mar 2021 09:54:13 +0800 Subject: [PATCH] groupName can't be empty. (#5196) --- .../com/alibaba/nacos/api/naming/utils/NamingUtils.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/utils/NamingUtils.java b/api/src/main/java/com/alibaba/nacos/api/naming/utils/NamingUtils.java index 56272bdbc..962903b84 100644 --- a/api/src/main/java/com/alibaba/nacos/api/naming/utils/NamingUtils.java +++ b/api/src/main/java/com/alibaba/nacos/api/naming/utils/NamingUtils.java @@ -46,6 +46,9 @@ public class NamingUtils { if (StringUtils.isBlank(serviceName)) { throw new IllegalArgumentException("Param 'serviceName' is illegal, serviceName is blank"); } + if (StringUtils.isBlank(groupName)) { + throw new IllegalArgumentException("Param 'groupName' is illegal, groupName is blank"); + } final String resultGroupedName = groupName + Constants.SERVICE_INFO_SPLITER + serviceName; return resultGroupedName.intern(); } @@ -75,7 +78,7 @@ public class NamingUtils { *
* serviceName = "@@"; the length = 0; illegal * serviceName = "group@@"; the length = 1; illegal - * serviceName = "@@serviceName"; the length = 2; legal + * serviceName = "@@serviceName"; the length = 2; illegal * serviceName = "group@@serviceName"; the length = 2; legal ** @@ -87,6 +90,9 @@ public class NamingUtils { throw new IllegalArgumentException( "Param 'serviceName' is illegal, it should be format as 'groupName@@serviceName'"); } + if (split[0].isEmpty()) { + throw new IllegalArgumentException("Param 'serviceName' is illegal, groupName can't be empty"); + } } /**