You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "AlbumenJ (via GitHub)" <gi...@apache.org> on 2023/06/20 06:18:28 UTC

[GitHub] [dubbo] AlbumenJ commented on a diff in pull request #12575: Triple set resolve fallback enable as default

AlbumenJ commented on code in PR #12575:
URL: https://github.com/apache/dubbo/pull/12575#discussion_r1234785994


##########
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocol.java:
##########
@@ -113,9 +114,26 @@ public void afterUnExport() {
 
         invokers.add(invoker);
 
-        pathResolver.add(url.getServiceKey(), invoker);
+        Invoker<?> previous = pathResolver.add(url.getServiceKey(), invoker);
+        if (previous != null) {
+            String msg = "Already exists an invoker[" + previous.getUrl() + "] on path[" + url.getServiceKey()
+                + "], dubbo will override with invoker[" + url + "]";
+            if (url.getServiceKey().equals(url.getServiceModel().getServiceModel().getInterfaceName())) {
+                logger.info(msg);
+            } else {
+                logger.warn(LoggerCodeConstants.PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", msg);
+            }
+        }
         if (RESOLVE_FALLBACK_TO_DEFAULT) {
-            pathResolver.add(url.getServiceModel().getServiceModel().getInterfaceName(), invoker);
+            previous = pathResolver.addIfAbsent(url.getServiceModel().getServiceModel().getInterfaceName(), invoker);

Review Comment:
   `addIfAbsent` 是为了不让 fallback 的空版本号覆盖真正空版本号的服务



-- 
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