Skip to content

Commit 35c719b

Browse files
committed
优化Eureka破窗实现
1 parent d76f099 commit 35c719b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spring-cloud-gray-plugins/spring-cloud-gray-plugin-eureka/src/main/java/cn/springcloud/gray/client/netflix/eureka/EurekaServerListProcessor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public List<Server> process(String serviceId, List<Server> servers) {
5353

5454
List<Server> serverList = null;
5555

56-
if(grayHoldoutServerProperties.isCacheable()) {
56+
if (grayHoldoutServerProperties.isCacheable()) {
5757
serverList = serversMap.get(serviceId);
5858
if (CollectionUtils.isNotEmpty(serverList)) {
5959
return serverList;
@@ -65,7 +65,7 @@ public List<Server> process(String serviceId, List<Server> servers) {
6565
if (CollectionUtils.isNotEmpty(unUpServers)) {
6666
serverList = ListUtils.union(servers, unUpServers);
6767
}
68-
if(grayHoldoutServerProperties.isCacheable()){
68+
if (grayHoldoutServerProperties.isCacheable()) {
6969
serversMap.put(serviceId, serverList);
7070
}
7171
return serverList;
@@ -130,6 +130,11 @@ public void onApplicationEvent(RefreshScopeRefreshedEvent event) {
130130
}
131131

132132
public void reload() {
133+
if (!grayHoldoutServerProperties.isEnabled()) {
134+
unUpServersMap.clear();
135+
serversMap.clear();
136+
return;
137+
}
133138
if (!semaphore.tryAcquire()) {
134139
log.info("已有其它线程在执行reload");
135140
return;

0 commit comments

Comments
 (0)