guohao commented on a change in pull request #8492: URL: https://github.com/apache/dubbo/pull/8492#discussion_r688245151
########## File path: dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/InstanceAddressUrlListener.java ########## @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.registry.client; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.extension.Activate; +import org.apache.dubbo.common.utils.CollectionUtils; +import org.apache.dubbo.registry.AddressListener; +import org.apache.dubbo.rpc.cluster.Directory; + +import java.util.List; + +/** + * Add consumerUrl information + */ +@Activate(order = 0) +public class InstanceAddressUrlListener implements AddressListener { + @Override + public List<URL> notify(List<URL> addresses, URL consumerUrl, Directory registryDirectory) { + + if (CollectionUtils.isNotEmpty(addresses)) { + for (URL url : addresses) { + if (url instanceof InstanceAddressURL) { + url.addParametersIfAbsent(consumerUrl.getParameters()); + } Review comment: `InstanceURL` is a application level URL which contains multiple service URLs, so `consumerUrl` in service level should not be add to `InstanceURL` ########## File path: dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/InstanceAddressURL.java ########## @@ -62,30 +62,38 @@ public MetadataInfo getMetadataInfo() { @Override public String getServiceInterface() { - return RpcContext.getServiceContext().getInterfaceName(); + String serviceInterface = RpcContext.getServiceContext().getInterfaceName(); + return StringUtils.isEmpty(serviceInterface) ? super.getParameter(INTERFACE_KEY) : serviceInterface; } + @Override public String getGroup() { - return RpcContext.getServiceContext().getGroup(); + String group = RpcContext.getServiceContext().getGroup(); + return StringUtils.isEmpty(group) ? super.getGroup() : group; Review comment: `super.getGroup()/getVersion()/getServiceInterface()` will call `getParameter()` internally and will cause recursive calls to `super.getXXX()` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
