From 8190b0f4a10903b177f6cbf6d5b2f73a9e385b9e Mon Sep 17 00:00:00 2001 From: fangjian0423 Date: Wed, 24 Oct 2018 16:54:18 +0800 Subject: [PATCH] remove duplicate and put once in datasource registry. --- .../sentinel/datasource/SentinelDataSourceRegistry.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-cloud-alibaba-sentinel-datasource/src/main/java/org/springframework/cloud/alibaba/sentinel/datasource/SentinelDataSourceRegistry.java b/spring-cloud-alibaba-sentinel-datasource/src/main/java/org/springframework/cloud/alibaba/sentinel/datasource/SentinelDataSourceRegistry.java index ac9feb089..5108196b5 100644 --- a/spring-cloud-alibaba-sentinel-datasource/src/main/java/org/springframework/cloud/alibaba/sentinel/datasource/SentinelDataSourceRegistry.java +++ b/spring-cloud-alibaba-sentinel-datasource/src/main/java/org/springframework/cloud/alibaba/sentinel/datasource/SentinelDataSourceRegistry.java @@ -16,7 +16,7 @@ package org.springframework.cloud.alibaba.sentinel.datasource; -import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; import com.alibaba.csp.sentinel.datasource.ReadableDataSource; @@ -38,7 +38,7 @@ import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.Zookeep */ public class SentinelDataSourceRegistry { - private static ConcurrentHashMap> cache = new ConcurrentHashMap<>( + private static HashMap> cache = new HashMap<>( 32); static { @@ -54,7 +54,6 @@ public class SentinelDataSourceRegistry { public static synchronized void registerFactoryBean(String alias, Class clazz) { - cache.putIfAbsent(alias, clazz); cache.put(alias, clazz); }