From 99a00ba72b53d6f740899ddb76c858b8f99683ac Mon Sep 17 00:00:00 2001 From: jingui123 <583789457@qq.com> Date: Tue, 30 Oct 2018 10:24:45 +0800 Subject: [PATCH] Optimize REGISTRIES field in AbstractRegistryFactory. (#2703) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modify ConcurrentHashMap to HashMap.这里REGISTRIES在使用的时候都会先加锁,不存在多线程安全的问题。所以这里建议使用hashmap * modify ConcurrentHashMap to HashMap.这里REGISTRIES在使用的时候都会先加锁,不存在多线程安全的问题。所以这里建议使用hashmap --- .../dubbo/registry/support/AbstractRegistryFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java index 8347d9a687f..64647f4ba60 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/AbstractRegistryFactory.java @@ -26,8 +26,8 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantLock; /** @@ -44,7 +44,7 @@ public abstract class AbstractRegistryFactory implements RegistryFactory { private static final ReentrantLock LOCK = new ReentrantLock(); // Registry Collection Map - private static final Map REGISTRIES = new ConcurrentHashMap(); + private static final Map REGISTRIES = new HashMap<>(); /** * Get all registries