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

[Dubbo-3629] Fix ServiceConfig duplicate export produces misleading exception #3649

Closed
wants to merge 3 commits into from

Conversation

JerryChin
Copy link

@JerryChin JerryChin commented Mar 14, 2019

What is the purpose of the change

fix #3629

First, the existing implementation by using two variables for controlling ServiceConfig exporting state is not only awkward to code, but also can theoretically lead invalid state transitions (exported and unexported both simultaneously true).

Secondly, the exported is set in doExport() method which could be called asynchronously, this makes it hard to refactor to prevent duplication exporting.

Brief changelog

the following changes are introduced:

  1. refactor the two variables exported and unexported into one AtomicInteger variable exportingStage.
  2. compare and set exporting state in export() and unexport() methods before doing anything.
  3. remove the synchronized from the two methods.
  4. add unit-test for this fix to verify everything works as expected.

The existing exporting state transition flow is as follows, remains unchanged after this PR :

        +----------------+
        | INITIAL_STAGE  |
        +----------------+
              |     ^
              |     |
              V     |
        +-----------------+
        | EXPORTING_STAGE |
        +-----------------+
                 |
                 |
                 V
        +-----------------+
        | EXPORTED_STAGE |
        +-----------------+
                 |
                 |
                 V
        +-----------------+
        | UNEXPORTED_STAGE|
        +-----------------+

Verifying this change

Necessary unit-test is added, see ServiceConfigTest

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

@CLAassistant
Copy link

CLAassistant commented Sep 6, 2019

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ JerryChin
❌ meijieqin
You have signed the CLA already but the status is still pending? Let us recheck it.

@AlbumenJ
Copy link
Member

@JerryChin hi, thanks for your contribution

Please merge the latest master branch to resolve conflict file

@AlbumenJ AlbumenJ added the status/waiting-for-feedback Need reporters to triage label Apr 11, 2021
@AlbumenJ
Copy link
Member

Close for long time no response.

Please feel free to reopen if you have any question.

If you think these changes still useful in the latest master branch, please submit a new pull request.

@AlbumenJ AlbumenJ closed this May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-for-feedback Need reporters to triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ServiceConfig duplicate export produces misleading exception
3 participants