chengyouling commented on code in PR #4709:
URL:
https://github.com/apache/servicecomb-java-chassis/pull/4709#discussion_r1945791303
##########
foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/discovery/InstanceStatusDiscoveryFilter.java:
##########
@@ -32,14 +32,23 @@ public class InstanceStatusDiscoveryFilter extends
AbstractGroupDiscoveryFilter
public static final String GROUP_SIZE = "status_group_size";
+ private String filterEnabledPropertyKey;
+
@Override
public int getOrder() {
return -10000;
}
@Override
public boolean enabled() {
- return
environment.getProperty("servicecomb.loadbalance.filter.status.enabled",
Boolean.class, true);
+
+ if (enabled == null) {
+ filterEnabledPropertyKey =
"servicecomb.loadbalance.filter.status.enabled";
Review Comment:
直接定义为静态成员变量
##########
foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/discovery/InstanceStatusDiscoveryFilter.java:
##########
@@ -32,14 +32,23 @@ public class InstanceStatusDiscoveryFilter extends
AbstractGroupDiscoveryFilter
public static final String GROUP_SIZE = "status_group_size";
+ private String filterEnabledPropertyKey;
+
@Override
public int getOrder() {
return -10000;
}
@Override
public boolean enabled() {
- return
environment.getProperty("servicecomb.loadbalance.filter.status.enabled",
Boolean.class, true);
+
+ if (enabled == null) {
+ filterEnabledPropertyKey =
"servicecomb.loadbalance.filter.status.enabled";
+ enabled = dynamicProperties.getBooleanProperty(filterEnabledPropertyKey,
+ value -> enabled = value,
+ true);
+ }
+ return enabled;
Review Comment:
整改方法用三元表达式处理就可以
##########
handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/InstancePropertyDiscoveryFilter.java:
##########
@@ -42,8 +42,13 @@ public int getOrder() {
@Override
public boolean enabled() {
- return
environment.getProperty("servicecomb.loadbalance.filter.instanceProperty.enabled",
- boolean.class, true);
+
+ if (enabled == null) {
Review Comment:
下面类似的地方统一用三元表达式处理下
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]