dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JerryChin (GitHub) <git...@apache.org>
Subject [GitHub] [incubator-dubbo] JerryChin opened pull request #3649: [Dubbo-3629] Fix ServiceConfig duplicate export produces misleading exception
Date Thu, 14 Mar 2019 03:32:15 GMT
## 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:

- [x] Make sure there is a [GITHUB_issue](https://github.com/apache/incubator-dubbo/issues)
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.
- [x] 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.
- [x] Write a pull request description that is detailed enough to understand what the pull
request does, how, and why.
- [x] 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](https://github.com/apache/incubator-dubbo/tree/master/dubbo-test).
- [x] 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](https://github.com/apache/incubator-dubbo/wiki/Software-donation-guide).


[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3649 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


Mime
View raw message