From 7b8019fef6792a00910c6d77d83873a669d8023c Mon Sep 17 00:00:00 2001 From: Wang Chengming <634749869@qq.com> Date: Thu, 19 May 2022 13:15:11 +0800 Subject: [PATCH] [3.0] fix #10045, fix unsupported operation list (#10049) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix #10045, use ArrayList * fix checkstyle * fix #10045, fix unsupported operation lis Co-authored-by: 呈铭 --- .../event/listener/ServiceInstancesChangedListener.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java index 9b36e6d163..3604b18d43 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java @@ -417,10 +417,13 @@ public class ServiceInstancesChangedListener { } protected List toUrlsWithEmpty(List urls) { - if (urls == null) { + boolean emptyProtectionEnabled = serviceDiscovery.getUrl().getParameter(ENABLE_EMPTY_PROTECTION_KEY, true); + if (!emptyProtectionEnabled && urls == null) { + urls = new ArrayList<>(); + } else if (emptyProtectionEnabled && urls == null) { urls = Collections.emptyList(); } - boolean emptyProtectionEnabled = serviceDiscovery.getUrl().getParameter(ENABLE_EMPTY_PROTECTION_KEY, true); + if (CollectionUtils.isEmpty(urls) && !emptyProtectionEnabled) { // notice that the service of this.url may not be the same as notify listener. URL empty = URLBuilder.from(this.url)