You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/11/15 06:58:57 UTC

[GitHub] [dubbo] CrazyHZM commented on a diff in pull request #10937: Fix the warning problem when invokerUrls is checked

CrazyHZM commented on code in PR #10937:
URL: https://github.com/apache/dubbo/pull/10937#discussion_r1022384042


##########
dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java:
##########
@@ -231,14 +231,14 @@ private void refreshInvoker(List<URL> invokerUrls) {
             }
             // use local reference to avoid NPE as this.cachedInvokerUrls will be set null by destroyAllInvokers().
             Set<URL> localCachedInvokerUrls = this.cachedInvokerUrls;
-            if (invokerUrls.isEmpty() && localCachedInvokerUrls != null) {
-
-                // 1-4 Empty address.
-                logger.warn(REGISTRY_EMPTY_ADDRESS, "configuration ", "",
-                    "Service" + serviceKey + " received empty address list with no EMPTY protocol set, trigger empty protection.");
-
-                invokerUrls.addAll(localCachedInvokerUrls);
+            if (invokerUrls.isEmpty()) {
+                if(localCachedInvokerUrls != null){
+                    // 1-4 Empty address.
+                    logger.warn(REGISTRY_EMPTY_ADDRESS, "configuration ", "",
+                        "Service" + serviceKey + " received empty address list with no EMPTY protocol set, trigger empty protection.");
 
+                    invokerUrls.addAll(localCachedInvokerUrls);
+                }

Review Comment:
   Agree with @AlbumenJ 
   A small suggestion:  use `CollectionUtils.isNotEmpty` to judge empty



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org