optimize some code for RegistryServerSync (#822)
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
index 475bb31..3e66694 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
@@ -28,6 +28,7 @@
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.Registry;
+
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@@ -41,7 +42,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicLong;
@Component
public class RegistryServerSync implements DisposableBean, NotifyListener {
@@ -60,8 +60,6 @@
Constants.ENABLED_KEY, Constants.ANY_VALUE,
Constants.CHECK_KEY, String.valueOf(false));
- private static final AtomicLong ID = new AtomicLong();
-
/**
* Make sure ID never changed when the same url notified many times
*/
@@ -88,7 +86,7 @@
registry.unsubscribe(SUBSCRIBE, this);
}
- // Notification of of any service with any type (override、subcribe、route、provider) is full.
+ // Notification of any service with any type (override、subscribe、route、provider) is full.
@Override
public void notify(List<URL> urls) {
if (urls == null || urls.isEmpty()) {
@@ -157,12 +155,12 @@
String category = categoryEntry.getKey();
ConcurrentMap<String, Map<String, URL>> services = interfaceRegistryCache.get(category);
if (services == null) {
- services = new ConcurrentHashMap<String, Map<String, URL>>();
+ services = new ConcurrentHashMap<>();
interfaceRegistryCache.put(category, services);
} else {// Fix map can not be cleared when service is unregistered: when a unique “group/service:version” service is unregistered, but we still have the same services with different version or group, so empty protocols can not be invoked.
- Set<String> keys = new HashSet<String>(services.keySet());
+ Set<String> keys = new HashSet<>(services.keySet());
for (String key : keys) {
- if (Tool.getInterface(key).equals(interfaceName) && !categoryEntry.getValue().entrySet().contains(key)) {
+ if (Tool.getInterface(key).equals(interfaceName) && !categoryEntry.getValue().containsKey(key)) {
services.remove(key);
}
}