Skip to content

Fixed a bug where the provider did not correctly inject the token#5697

Merged
chickenlj merged 1 commit intoapache:masterfrom
manzhizhen:token-invalidation-bug
Jan 31, 2020
Merged

Fixed a bug where the provider did not correctly inject the token#5697
chickenlj merged 1 commit intoapache:masterfrom
manzhizhen:token-invalidation-bug

Conversation

@manzhizhen
Copy link
Copy Markdown

@manzhizhen manzhizhen commented Jan 27, 2020

我发现一个可能一直存在的问题,就是我们的token机制没有被正确使用,我之前使用的dubbo-2.5.3版本就有这个问题,最近我在使用dubbo-2.7.5版本时发现这个问题仍然存在。
I found a problem that may have existed all the time, that is, our token mechanism has not been used correctly. This problem existed in dubbo-2.5.3, which I used before. Recently, when I used dubbo-2.7.5, I found that this problem still exists.

现象:
当token设置成true时,provider没有将token的UUID正确注入到注册中心的bug,例如:
Phenomenon:
When the token is set to true, the provider does not correctly inject the UUID of the token into the bug in the registry, for example:
<dubbo:provider token="true" filter="SystemParamProviderFilter,DLProviderFilter,MetricsProviderFilter"/>

我在provider端暴露了一个dubbo协议的接口:com.manzhizhen.dubbo.api.Dubbo1Service,结果我在注册中心上(zookeeper)看到的结果如下:
I exposed an interface of Dubbo protocol on the provider side: com.manzhen.dubbo.api.dubbo1service. As a result, the results I saw on the zookeeper are as follows:

[zk: localhost:2181(CONNECTED) 12] ls /dubbo/com.manzhizhen.dubbo.api.Dubbo1Service/providers
[dubbo://192.168.1.6:4445/com.manzhizhen.dubbo.api.Dubbo1Service?anyhost=true&application=mzz-dubbo1&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&interface=com.manzhizhen.dubbo.api.Dubbo1Service&methods=study&pid=5808&release=2.7.5&revision=1.0.0&service.filter=SystemParamProviderFilter,DLProviderFilter,MetricsProviderFilter&side=provider&threads=10&timestamp=1580090144366&token=true&version=1.0.0]

注意,其中token=true,但其实应该是token=某个UUID,而不是true。
Note that token = true, but it should be token = a UUID instead of true.

下面是我修改代码后的效果:
Here is the effect after I modify the code:

[zk: localhost:2181(CONNECTED) 14] ls /dubbo/com.manzhizhen.dubbo.api.Dubbo1Service/providers
[dubbo%3A%2F%2F192.168.1.6%3A4445%2Fcom.manzhizhen.dubbo.api.Dubbo1Service%3Fanyhost%3Dtrue%26application%3Dmzz-dubbo1%26deprecated%3Dfalse%26dubbo%3D2.0.2%26dynamic%3Dtrue%26generic%3Dfalse%26interface%3Dcom.manzhizhen.dubbo.api.Dubbo1Service%26methods%3Dstudy%26pid%3D13360%26release%3D2.7.5-didi-yzq-2-SNAPSHOT%26revision%3D1.0.0%26service.filter%3DSystemParamProviderFilter%2CDLProviderFilter%2CMetricsProviderFilter%26side%3Dprovider%26threads%3D10%26timestamp%3D1580096635841%26token%3D89b5748a-8016-454d-940c-89d53d78f104%26version%3D1.0.0]

这里显示了正确的效果,token=89b5748a-8016-454d-940c-89d53d78f104,一个UUID的值。
The correct effect is shown here, token = 89b5748a-8016-454d-940c-89d53d78f104, a UUID value.

这符合之前org.apache.dubbo.config.ServiceConfig中的代码逻辑:
This is in line with the previous code logic in org.apache.dubbo.config.Serviceconfig:

        if (!ConfigUtils.isEmpty(token)) {
            if (ConfigUtils.isDefault(token)) {
                map.put(TOKEN_KEY, UUID.randomUUID().toString());
            } else {
                map.put(TOKEN_KEY, token);
            }
        }

此次PR还修复了dubbo-all中缺失的两个模块依赖问题,所以我们在dubbo-all/pom.xml中添加了遗漏的dubbo-remoting-etcd3和dubbo-registry-eureka模块。
This PR also fixed two missing module dependencies in Dubbo all, so we added the missing Dubbo remoting etcd3 and Dubbo registry Eureka modules in Dubbo all / pom.xml.

…UID into the registry when the token was set to true; added the missing dubbo-remoting-etcd3 and dubbo-registry-eureka modules in dubbo-all / pom.xml
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #5697 into master will decrease coverage by 0.18%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #5697      +/-   ##
============================================
- Coverage     61.34%   61.16%   -0.19%     
- Complexity      425      471      +46     
============================================
  Files           923      925       +2     
  Lines         37572    37781     +209     
  Branches       5442     5450       +8     
============================================
+ Hits          23047    23107      +60     
- Misses        12043    12172     +129     
- Partials       2482     2502      +20
Impacted Files Coverage Δ Complexity Δ
...in/java/org/apache/dubbo/config/ServiceConfig.java 62.18% <50%> (-0.08%) 0 <0> (ø)
...rg/apache/dubbo/remoting/utils/PayloadDropper.java 46.15% <0%> (-30.77%) 0% <0%> (ø)
.../apache/dubbo/rpc/protocol/AsyncToSyncInvoker.java 70.83% <0%> (-16.67%) 0% <0%> (ø)
...va/org/apache/dubbo/remoting/TimeoutException.java 22.22% <0%> (-11.12%) 0% <0%> (ø)
...dubbo/remoting/exchange/support/DefaultFuture.java 75.67% <0%> (-10.82%) 0% <0%> (ø)
.../apache/dubbo/remoting/transport/AbstractPeer.java 58.69% <0%> (-8.7%) 0% <0%> (ø)
...ng/transport/dispatcher/all/AllChannelHandler.java 68.96% <0%> (-6.9%) 0% <0%> (ø)
...he/dubbo/common/threadpool/ThreadlessExecutor.java 55% <0%> (-5%) 0% <0%> (ø)
...e/dubbo/remoting/transport/netty/NettyChannel.java 55.68% <0%> (-4.55%) 20% <0%> (-1%)
...pache/dubbo/remoting/transport/AbstractServer.java 53.75% <0%> (-3.75%) 0% <0%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e234a89...4c663fb. Read the comment docs.

@chickenlj
Copy link
Copy Markdown
Contributor

LGTM.

@chickenlj chickenlj merged commit 8bec976 into apache:master Jan 31, 2020
@chickenlj chickenlj added this to the 2.7.6 milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants