<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/incubator-dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/apache/incubator-dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.1+</li>
<li>Operating System version: mac</li>
<li>Java version: jdk</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    &lt;dependencies&gt;
        ...
        &lt;dependency&gt;
            &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
            &lt;artifactId&gt;hessian-lite&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
            &lt;artifactId&gt;fastjson&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.esotericsoftware&lt;/groupId&gt;
            &lt;artifactId&gt;kryo&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;de.javakaffee&lt;/groupId&gt;
            &lt;artifactId&gt;kryo-serializers&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;de.ruedigermoeller&lt;/groupId&gt;
            &lt;artifactId&gt;fst&lt;/artifactId&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;"><pre class="notranslate">    &lt;<span class="pl-ent">dependencies</span>&gt;
        ...
        &lt;<span class="pl-ent">dependency</span>&gt;
            &lt;<span class="pl-ent">groupId</span>&gt;com.alibaba&lt;/<span class="pl-ent">groupId</span>&gt;
            &lt;<span class="pl-ent">artifactId</span>&gt;hessian-lite&lt;/<span class="pl-ent">artifactId</span>&gt;
        &lt;/<span class="pl-ent">dependency</span>&gt;
        &lt;<span class="pl-ent">dependency</span>&gt;
            &lt;<span class="pl-ent">groupId</span>&gt;com.alibaba&lt;/<span class="pl-ent">groupId</span>&gt;
            &lt;<span class="pl-ent">artifactId</span>&gt;fastjson&lt;/<span class="pl-ent">artifactId</span>&gt;
        &lt;/<span class="pl-ent">dependency</span>&gt;
        &lt;<span class="pl-ent">dependency</span>&gt;
            &lt;<span class="pl-ent">groupId</span>&gt;com.esotericsoftware&lt;/<span class="pl-ent">groupId</span>&gt;
            &lt;<span class="pl-ent">artifactId</span>&gt;kryo&lt;/<span class="pl-ent">artifactId</span>&gt;
        &lt;/<span class="pl-ent">dependency</span>&gt;
        &lt;<span class="pl-ent">dependency</span>&gt;
            &lt;<span class="pl-ent">groupId</span>&gt;de.javakaffee&lt;/<span class="pl-ent">groupId</span>&gt;
            &lt;<span class="pl-ent">artifactId</span>&gt;kryo-serializers&lt;/<span class="pl-ent">artifactId</span>&gt;
        &lt;/<span class="pl-ent">dependency</span>&gt;
        &lt;<span class="pl-ent">dependency</span>&gt;
            &lt;<span class="pl-ent">groupId</span>&gt;de.ruedigermoeller&lt;/<span class="pl-ent">groupId</span>&gt;
            &lt;<span class="pl-ent">artifactId</span>&gt;fst&lt;/<span class="pl-ent">artifactId</span>&gt;
        &lt;/<span class="pl-ent">dependency</span>&gt;
    &lt;/<span class="pl-ent">dependencies</span>&gt;</pre></div>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>
<h1 dir="auto">Set consumer tag by RpcContext doesn't work</h1>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.7</li>
<li>Operating System version: macOS 10.15.5</li>
<li>Java version: OpenJDK 11.0.7 2020-04-14</li>
<li>Config Center: nacos 1.3.0</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto"><a href="https://github.com/konanok/dubbo-demo">demo</a></p>
<ol dir="auto">
<li>start <a href="https://github.com/konanok/dubbo-demo/tree/master/dubbo-provider-demo">dubbo-provider-demo</a> with no tag</li>
<li>start <a href="https://github.com/konanok/dubbo-demo/tree/master/dubbo-consumer-demo">dubbo-consumer-demo</a> with <a href="https://github.com/konanok/dubbo-demo/blob/master/dubbo-spi/src/main/java/org/konanok/demo/dubbo/spi/router/DynamicTagRouter.java">DynamicTagRouter</a>, and it will set the consumer tag with "A"</li>
</ol>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="RpcContext.getContext().setAttachment(CommonConstants.TAG_KEY, tag);"><pre class="notranslate"><span class="pl-smi">RpcContext</span>.<span class="pl-en">getContext</span>().<span class="pl-en">setAttachment</span>(<span class="pl-smi">CommonConstants</span>.<span class="pl-c1">TAG_KEY</span>, <span class="pl-s1">tag</span>);</pre></div>
<ol start="3" dir="auto">
<li>create dubbo-provider-demo.tag-router on nacos</li>
</ol>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="enabled: true
force: true
key: dubbo-provider-demo
priority: 0
runtime: true
tags:
- addresses:
  - 192.168.80.8:21881
  name: A"><pre class="notranslate"><span class="pl-ent">enabled</span>: <span class="pl-c1">true</span>
<span class="pl-ent">force</span>: <span class="pl-c1">true</span>
<span class="pl-ent">key</span>: <span class="pl-s">dubbo-provider-demo</span>
<span class="pl-ent">priority</span>: <span class="pl-c1">0</span>
<span class="pl-ent">runtime</span>: <span class="pl-c1">true</span>
<span class="pl-ent">tags</span>:
- <span class="pl-ent">addresses</span>:
  - <span class="pl-s">192.168.80.8:21881</span>
  <span class="pl-ent">name</span>: <span class="pl-s">A</span></pre></div>
<ol start="4" dir="auto">
<li>invoke dubbo-consumer-demo's http-api to invoke dubbo-provider-demo's dubbo-api</li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="curl http://localhost:8282/dubbo/hello"><pre class="notranslate">curl http://localhost:8282/dubbo/hello</pre></div>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">Response successfully, such as:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Hello from host 192.168.80.8 at 2020-07-01 10:21:00"><pre lang="text" class="notranslate"><code class="notranslate">Hello from host 192.168.80.8 at 2020-07-01 10:21:00
</code></pre></div>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">Response error, is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{&quot;timestamp&quot;:&quot;2020-07-01T02:24:40.794+0000&quot;,&quot;status&quot;:500,&quot;error&quot;:&quot;Internal Server Error&quot;,&quot;message&quot;:&quot;Failed to invoke the method hello in the service org.konanok.demo.dubbo.api.IDubboService. No provider available for the service org.konanok.demo.dubbo.api.IDubboService from registry 192.168.80.240:8851 on the consumer 192.168.80.8 using the dubbo version 2.7.7. Please check if the providers have been started and registered.&quot;,&quot;path&quot;:&quot;/dubbo/hello&quot;}"><pre lang="text" class="notranslate"><code class="notranslate">{"timestamp":"2020-07-01T02:24:40.794+0000","status":500,"error":"Internal Server Error","message":"Failed to invoke the method hello in the service org.konanok.demo.dubbo.api.IDubboService. No provider available for the service org.konanok.demo.dubbo.api.IDubboService from registry 192.168.80.240:8851 on the consumer 192.168.80.8 using the dubbo version 2.7.7. Please check if the providers have been started and registered.","path":"/dubbo/hello"}
</code></pre></div>
<p dir="auto">YouTrack:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR 95351 --- [nio-8282-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.dubbo.rpc.RpcException: Failed to invoke the method hello in the service org.konanok.demo.dubbo.api.IDubboService. No provider available for the service org.konanok.demo.dubbo.api.IDubboService from registry 192.168.80.240:8848 on the consumer 192.168.80.8 using the dubbo version 2.7.7. Please check if the providers have been started and registered.] with root cause

org.apache.dubbo.rpc.RpcException: Failed to invoke the method hello in the service org.konanok.demo.dubbo.api.IDubboService. No provider available for the service org.konanok.demo.dubbo.api.IDubboService from registry 192.168.80.240:8848 on the consumer 192.168.80.8 using the dubbo version 2.7.7. Please check if the providers have been started and registered.
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.checkInvokers(AbstractClusterInvoker.java:282) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:59) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:259) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:82) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.common.bytecode.proxy0.hello(proxy0.java) ~[dubbo-2.7.7.jar:2.7.7]
	at org.konanok.demo.dubbo.consumer.controller.DubboController.hello(DubboController.java:19) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]"><pre lang="youtrack" class="notranslate"><code class="notranslate">ERROR 95351 --- [nio-8282-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.dubbo.rpc.RpcException: Failed to invoke the method hello in the service org.konanok.demo.dubbo.api.IDubboService. No provider available for the service org.konanok.demo.dubbo.api.IDubboService from registry 192.168.80.240:8848 on the consumer 192.168.80.8 using the dubbo version 2.7.7. Please check if the providers have been started and registered.] with root cause

org.apache.dubbo.rpc.RpcException: Failed to invoke the method hello in the service org.konanok.demo.dubbo.api.IDubboService. No provider available for the service org.konanok.demo.dubbo.api.IDubboService from registry 192.168.80.240:8848 on the consumer 192.168.80.8 using the dubbo version 2.7.7. Please check if the providers have been started and registered.
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.checkInvokers(AbstractClusterInvoker.java:282) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:59) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:259) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:82) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:74) ~[dubbo-2.7.7.jar:2.7.7]
	at org.apache.dubbo.common.bytecode.proxy0.hello(proxy0.java) ~[dubbo-2.7.7.jar:2.7.7]
	at org.konanok.demo.dubbo.consumer.controller.DubboController.hello(DubboController.java:19) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.34.jar:9.0.34]
	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
</code></pre></div>
<h3 dir="auto">Question</h3>
<p dir="auto">I read the TagRouter source code, and notice that, on <strong>Line 100</strong>, dubbo try to get the consumer's tag from <strong>URL</strong> and <strong>Invocation</strong> only, but not <strong>RpcContext</strong>.</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Override
public &lt;T&gt; List&lt;Invoker&lt;T&gt;&gt; route(List&lt;Invoker&lt;T&gt;&gt; invokers, URL url, Invocation invocation) throws RpcException {
    // ...

    String tag = StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? url.getParameter(TAG_KEY) :
            invocation.getAttachment(TAG_KEY);

    // ...
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Override</span>
<span class="pl-k">public</span> &lt;<span class="pl-smi">T</span>&gt; <span class="pl-s1">List</span>&lt;<span class="pl-s1">Invoker</span>&lt;<span class="pl-s1">T</span>&gt;&gt; <span class="pl-s1">route</span>(<span class="pl-smi">List</span>&lt;<span class="pl-smi">Invoker</span>&lt;<span class="pl-smi">T</span>&gt;&gt; <span class="pl-s1">invokers</span>, <span class="pl-smi">URL</span> <span class="pl-s1">url</span>, <span class="pl-smi">Invocation</span> <span class="pl-s1">invocation</span>) <span class="pl-k">throws</span> <span class="pl-s1">RpcException</span> {
    <span class="pl-c">// ...</span>

    <span class="pl-smi">String</span> <span class="pl-s1">tag</span> = <span class="pl-smi">StringUtils</span>.<span class="pl-en">isEmpty</span>(<span class="pl-s1">invocation</span>.<span class="pl-en">getAttachment</span>(<span class="pl-c1">TAG_KEY</span>)) ? <span class="pl-s1">url</span>.<span class="pl-en">getParameter</span>(<span class="pl-c1">TAG_KEY</span>) :
            <span class="pl-s1">invocation</span>.<span class="pl-en">getAttachment</span>(<span class="pl-c1">TAG_KEY</span>);

    <span class="pl-c">// ...</span>
}</pre></div>
<p dir="auto"><a href="https://dubbo.apache.org/zh-cn/docs/user/demos/routing-rule.html" rel="nofollow">TagRouter Document</a> tell me to set consumer tag by <strong>RpcContext</strong>... <g-emoji class="g-emoji" alias="sweat" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f613.png">😓</g-emoji><g-emoji class="g-emoji" alias="sweat" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f613.png">😓</g-emoji><g-emoji class="g-emoji" alias="sweat" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f613.png">😓</g-emoji></p>
<blockquote>
<p dir="auto">RpcContext.getContext().setAttachment(Constants.REQUEST_TAG_KEY,"tag1");</p>
</blockquote>
<p dir="auto">The document also has a problem, <strong>Constants.REQUEST_TAG_KEY</strong> is gone, current correct key is <strong>CommonConstants.TAG_KEY</strong>, maybe someone should fix it.</p>
<p dir="auto">I have no idea that why dubbo didn't try to get tag from RpcContext at this place, does anybody can explain this? if not, I think RpcContext's attachment tag should have a high priority, and the code should be fixed such as:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Override
public &lt;T&gt; List&lt;Invoker&lt;T&gt;&gt; route(List&lt;Invoker&lt;T&gt;&gt; invokers, URL url, Invocation invocation) throws RpcException {
    // ...

    String tag = StringUtils.isEmpty(RpcContext.getContext().getAttachment(TAG_KEY)) ? (
            StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? 
                    url.getParameter(TAG_KEY) : 
                    invocation.getAttachment(TAG_KEY)) : 
            RpcContext.getContext().getAttachment(TAG_KEY);

    // ...
}"><pre class="notranslate"><span class="pl-c1">@</span><span class="pl-c1">Override</span>
<span class="pl-k">public</span> &lt;<span class="pl-smi">T</span>&gt; <span class="pl-s1">List</span>&lt;<span class="pl-s1">Invoker</span>&lt;<span class="pl-s1">T</span>&gt;&gt; <span class="pl-s1">route</span>(<span class="pl-smi">List</span>&lt;<span class="pl-smi">Invoker</span>&lt;<span class="pl-smi">T</span>&gt;&gt; <span class="pl-s1">invokers</span>, <span class="pl-smi">URL</span> <span class="pl-s1">url</span>, <span class="pl-smi">Invocation</span> <span class="pl-s1">invocation</span>) <span class="pl-k">throws</span> <span class="pl-s1">RpcException</span> {
    <span class="pl-c">// ...</span>

    <span class="pl-smi">String</span> <span class="pl-s1">tag</span> = <span class="pl-smi">StringUtils</span>.<span class="pl-en">isEmpty</span>(<span class="pl-smi">RpcContext</span>.<span class="pl-en">getContext</span>().<span class="pl-en">getAttachment</span>(<span class="pl-c1">TAG_KEY</span>)) ? (
            <span class="pl-smi">StringUtils</span>.<span class="pl-en">isEmpty</span>(<span class="pl-s1">invocation</span>.<span class="pl-en">getAttachment</span>(<span class="pl-c1">TAG_KEY</span>)) ? 
                    <span class="pl-s1">url</span>.<span class="pl-en">getParameter</span>(<span class="pl-c1">TAG_KEY</span>) : 
                    <span class="pl-s1">invocation</span>.<span class="pl-en">getAttachment</span>(<span class="pl-c1">TAG_KEY</span>)) : 
            <span class="pl-smi">RpcContext</span>.<span class="pl-en">getContext</span>().<span class="pl-en">getAttachment</span>(<span class="pl-c1">TAG_KEY</span>);

    <span class="pl-c">// ...</span>
}</pre></div>
<p dir="auto">Thanks!❤️</p>