Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get wrong default protocolConfig from another service. #4775

Closed
2 tasks done
haiyang1985 opened this issue Aug 8, 2019 · 8 comments
Closed
2 tasks done

get wrong default protocolConfig from another service. #4775

haiyang1985 opened this issue Aug 8, 2019 · 8 comments
Assignees
Milestone

Comments

@haiyang1985
Copy link
Member

haiyang1985 commented Aug 8, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.3
  • Operating System version: macOs
  • Java version: 1.8

Steps to reproduce this issue

  1. export service with protocolConfig defined as below in API mode.
ProtocolConfig protocolConfig = new ProtocolConfig();
protocolConfig.setPort(20880);
protocolConfig.setIothreads(2);

ServiceConfig messageService = new ServiceConfig();
messageService.setProtocol(protocolConfig);
  1. export another service with default protocol as below in XML mode.
<bean id="demoService" class="com.ctrip.framework.cdubbo.api.DemoServiceImpl"/>
<dubbo:service interface="com.ctrip.framework.cdubbo.api.DemoService" ref="demoService">
</dubbo:service>
  1. XML service get API service's protocol, which makes port and iothreads parameter incorrect.

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

XML service's port should in default 20880.

Actual Result

XML service's port is 20770, and iothreds is 2.

@chickenlj chickenlj added this to the 2.7.4 milestone Aug 8, 2019
@chickenlj chickenlj self-assigned this Aug 8, 2019
@tswstarplanet
Copy link
Contributor

Can you provide a demo ? I test but didn't reproduce the problem.

@chickenlj
Copy link
Contributor

@tswstarplanet I can reproduce this issue with the following config:

image

image

@haiyang1985
Copy link
Member Author

Can you provide a demo ? I test but didn't reproduce the problem.

Here is the demo for you, https://github.com/haiyang1985/dubbo-demo-config.
Start the ServiceInitializer, and catch URL from ZookeeperRegistry and you will see DemoService's port is 20770. Actually, it should not be impacted from DemoService2's protocol.

@tswstarplanet
Copy link
Contributor

I check the code, it's because when you export the DemoService2, the protocol is stored in ConfigManager as a "default" protocol, and when the DemoService is exported, the "default" protocol will be set to it.

@haiyang1985
Copy link
Member Author

@tswstarplanet yes.

@tswstarplanet
Copy link
Contributor

这个问题其实我感觉有点麻烦,因为目前dubbo的逻辑是如果一个protocol被添加到ConfigManager中时,如果没有设置id,default没有显式设置为false,那它保存的key就是default。所以上面把设置的protocol设置为default是合逻辑的。
如果要改的话,我想到的:
1.定义protocol必须显式指定default,如果不指定则不默认为default
2.基于1,如果没有定义protocol,或者定义了protocol,但是没有定义default为ture,那么就没有default的protocol,那么没有指定protocol的Service就没有ptotocol,初始化就报错
@chickenlj 你觉得这样可以吗

@chickenlj
Copy link
Contributor

1.定义protocol必须显式指定default,如果不指定则不默认为default

@tswstarplanet 这点和之前的默认逻辑相反,可能导致老用户配置的未指定default=true的protocol无法生效

@chickenlj
Copy link
Contributor

这个问题在 cloud-native 尝试做了解决,setProtocol 不再向 ConfigManager 保存全局实例。

@chickenlj chickenlj modified the milestones: 2.7.4, 2.7.5 Sep 9, 2019
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

No branches or pull requests

3 participants