diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/AbstractRule.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/AbstractRule.java index 9e160623..2a0d7260 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/AbstractRule.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/AbstractRule.java @@ -15,7 +15,9 @@ */ package com.alibaba.csp.sentinel.slots.block; -/*** +/** + * Abstract rule entity. + * * @author youji.zj * @author Eric Zhao */ @@ -29,10 +31,11 @@ public abstract class AbstractRule implements Rule { /** *
* Application name that will be limited by origin. - * Multiple application name can be separated with comma (','). + * The default limitApp is {@code default}, which means allowing all origin apps. + *
+ *+ * For authority rules, multiple origin name can be separated with comma (','). *
- *The default limitApp is `default`, which means allowing all origin apps.
- *For example: limitApp = `appA,appB` will limit requests from appA and appB.
*/ private String limitApp; @@ -68,8 +71,6 @@ public abstract class AbstractRule implements Rule { if (resource != null ? !resource.equals(that.resource) : that.resource != null) { return false; } - // if (limitApp != null ? !limitApp.equals(that.limitApp) : - // that.limitApp != null) { return false; } if (!limitAppEquals(limitApp, that.limitApp)) { return false; } @@ -78,12 +79,12 @@ public abstract class AbstractRule implements Rule { private boolean limitAppEquals(String str1, String str2) { if ("".equals(str1)) { - return "default".equals(str2); - } else if ("default".equals(str1)) { + return RuleConstant.LIMIT_APP_DEFAULT.equals(str2); + } else if (RuleConstant.LIMIT_APP_DEFAULT.equals(str1)) { return "".equals(str2) || str2 == null || str1.equals(str2); } if (str1 == null) { - return str2 == null || "default".equals(str2); + return str2 == null || RuleConstant.LIMIT_APP_DEFAULT.equals(str2); } return str1.equals(str2); } @@ -95,8 +96,7 @@ public abstract class AbstractRule implements Rule { @Override public int hashCode() { int result = resource != null ? resource.hashCode() : 0; - // result = 31 * result + (limitApp != null ? limitApp.hashCode() : 0); - if (!("".equals(limitApp) || "default".equals(limitApp) || limitApp == null)) { + if (!("".equals(limitApp) || RuleConstant.LIMIT_APP_DEFAULT.equals(limitApp) || limitApp == null)) { result = 31 * result + limitApp.hashCode(); } return result;