1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

不应该使用类实例访问静态成员\不应该直接使用不确定的值调用equals容易空指针\final static应该使用大写命名并且使用下划线

This commit is contained in:
eden-yuan
2020-12-07 17:17:41 +08:00
parent 569f3f02c1
commit c19bd51584
8 changed files with 14 additions and 14 deletions

View File

@@ -77,7 +77,7 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
/**
* Caches the IDs of {@link ApplicationListener}.
*/
private static final Set<String> registerListeners = new HashSet<>();
private static final Set<String> REGISTER_LISTENERS = new HashSet<>();
protected final Logger logger = LoggerFactory.getLogger(getClass());
@@ -193,7 +193,7 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
private void registerServiceInstancesChangedEventListener(URL url,
NotifyListener listener) {
String listenerId = generateId(url);
if (registerListeners.add(listenerId)) {
if (REGISTER_LISTENERS.add(listenerId)) {
applicationContext.addApplicationListener(
new ApplicationListener<ServiceInstancesChangedEvent>() {
@Override
@@ -261,7 +261,7 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
String listenerId = generateId(url);
// The metaservice will restart the new listener. It needs to be optimized
// to see whether the original listener can be reused.
this.registerListeners.remove(listenerId);
REGISTER_LISTENERS.remove(listenerId);
}
/**

View File

@@ -83,7 +83,7 @@ public class DubboCloudRegistry extends FailbackRegistry {
/**
* Caches the IDs of {@link ApplicationListener}.
*/
private static final Set<String> registerListeners = new HashSet<>();
private static final Set<String> REGISTER_LISTENERS = new HashSet<>();
protected final Logger logger = LoggerFactory.getLogger(getClass());
@@ -215,7 +215,7 @@ public class DubboCloudRegistry extends FailbackRegistry {
private void registerServiceInstancesChangedListener(URL url,
ApplicationListener<ServiceInstancesChangedEvent> listener) {
String listenerId = generateId(url);
if (registerListeners.add(listenerId)) {
if (REGISTER_LISTENERS.add(listenerId)) {
applicationContext.addApplicationListener(listener);
}
}