8000 DubboProtocol#INSTANCE should not be initialized in the constructor · Issue #7949 · apache/dubbo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

DubboProtocol#INSTANCE should not be initialized in the constructor #7949

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

Closed
2 tasks
xiaoheng1 opened this issue Jun 1, 2021 · 0 comments
Closed
2 tasks

Comments

@xiaoheng1
Copy link
Contributor
  • 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: master
  • Operating System version: macos
  • Java version: 1.8

movitation:

DubboProtocol#INSTANCE should not be initialized in the constructor

source code:

public DubboProtocol() {
        INSTANCE = this;
    }

This causes the result of Instance to change every time new DubboProtocol(). Although logically, DubboProtocol is semantically singleton, there is no guarantee that when writing test cases, users will not directly use new DubboProtocol(), so Suggest modifications to avoid potential problems.
In addition, assigning INSTANCE directly to this may cause this escape problem.

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

1 participant
0