xiaoheng1 opened a new issue #8491:
URL: https://github.com/apache/dubbo/issues/8491


   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) 
of this repository and believe that this is not a duplicate.
   - [ ] I have checked the 
[FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository 
and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.1
   * Operating System version: macos
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   link #8479
   
   In the service discovery scenario, when the consumer subscribes to the 
provider, the URL obtained is InstanceAddressURL.
   But the protocolServiceKey is obtained from ThreadLocal, and its setting is 
done in 
org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory#notify.
   
   for example:
   
   ```
   ServiceDiscoveryRegistryDirectory
   public synchronized void notify(List<URL> instanceUrls) {
           ......
           // Set the context of the address notification thread.
           RpcServiceContext.setRpcContext(getConsumerUrl());
   
           /**
            * 3.x added for extend URL address
            */
           ExtensionLoader<AddressListener> addressListenerExtensionLoader = 
ExtensionLoader.getExtensionLoader(AddressListener.class);
           List<AddressListener> supportedListeners = 
addressListenerExtensionLoader.getActivateExtension(getUrl(), (String[]) null);
           if (supportedListeners != null && !supportedListeners.isEmpty()) {
               for (AddressListener addressListener : supportedListeners) {
                   instanceUrls = addressListener.notify(instanceUrls, 
getConsumerUrl(), this);
               }
           }
   
           refreshOverrideAndInvoker(instanceUrls);
       }
   ```
   
   
   ```
   DubboInvoker
   protected Result doInvoke(final Invocation invocation) throws Throwable {
           RpcInvocation inv = (RpcInvocation) invocation;
           final String methodName = RpcUtils.getMethodName(invocation);
           inv.setAttachment(PATH_KEY, getUrl().getPath());
           inv.setAttachment(VERSION_KEY, version);
          ......
   ```
   
   The calling thread and the thread that set the consumerUrl are not the same 
thread, which will cause the consumerUrl to not be delivered.
   
   Solution:
   Modify the value of InstanceAddressURL through AddressListener to include 
consumerUrl, and then when InstanceAddressUrl gets the value, if it is empty, 
it will get it from its own URL property.


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

Reply via email to