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

Replace hard coded dubbo-config-api values and small code optimization #3108

Merged
merged 4 commits into from
Jan 2, 2019

Conversation

khanimteyaz
Copy link
Contributor

In this PR I have refactored code to

  1. Replace hard coded values from java code to constant. Most of this values where getting used from multiple places so moving to constant avoid development time or run time error for value mismatch.
  2. Small refactoring to reduce code volume and use existing JDK provided utility and operation.

Bellow are the java file which has been modified as part of this PR

dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
dubbo-common/src/main/java/org/apache/dubbo/common/EnvironmentConstants.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractServiceConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/MethodConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ModuleConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProviderConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java

What is the purpose of the change

  1. Replace hard coded values from java code to constant. Most of this values where getting used from multiple places so moving to constant avoid development time or run time error for value mismatch.
  2. Small refactoring to reduce code volume and use existing JDK provided utility and operation.

Brief changelog

Hard coded value replacement of dubbo-config-api and small refactoring to optimize code size.

Verifying this change

Running UT

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

  • Make sure there is a 3107 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.

@codecov-io
Copy link

codecov-io commented Jan 2, 2019

Codecov Report

Merging #3108 into master will increase coverage by 0.02%.
The diff coverage is 68.53%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3108      +/-   ##
============================================
+ Coverage     63.52%   63.54%   +0.02%     
  Complexity       75       75              
============================================
  Files           652      652              
  Lines         28183    28188       +5     
  Branches       4791     4784       -7     
============================================
+ Hits          17902    17913      +11     
+ Misses         8023     8014       -9     
- Partials       2258     2261       +3
Impacted Files Coverage Δ Complexity Δ
...c/main/java/org/apache/dubbo/common/Constants.java 92.85% <ø> (ø) 0 <0> (ø) ⬇️
...va/org/apache/dubbo/config/ConfigCenterConfig.java 31.03% <0%> (ø) 0 <0> (ø) ⬇️
...org/apache/dubbo/config/AbstractServiceConfig.java 95.77% <100%> (ø) 0 <0> (ø) ⬇️
...ava/org/apache/dubbo/config/ApplicationConfig.java 84.33% <100%> (+1.62%) 0 <0> (ø) ⬇️
...ain/java/org/apache/dubbo/config/ModuleConfig.java 86.84% <100%> (ø) 0 <0> (ø) ⬇️
...ain/java/org/apache/dubbo/config/MethodConfig.java 100% <100%> (+1.72%) 0 <0> (ø) ⬇️
...n/java/org/apache/dubbo/config/ProviderConfig.java 95.69% <100%> (ø) 0 <0> (ø) ⬇️
...n/java/org/apache/dubbo/config/RegistryConfig.java 84.21% <40%> (+1.85%) 0 <0> (ø) ⬇️
...n/java/org/apache/dubbo/config/ProtocolConfig.java 75.93% <42.85%> (ø) 0 <0> (ø) ⬇️
...in/java/org/apache/dubbo/config/ServiceConfig.java 53.74% <61.53%> (+0.39%) 0 <0> (ø) ⬇️
... and 12 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 d41408e...9ccc95a. Read the comment docs.

@beiwei30 beiwei30 merged commit e172b29 into apache:master Jan 2, 2019
@khanimteyaz khanimteyaz deleted the dubbo-config-refactor branch January 2, 2019 13:06
khanimteyaz added a commit to khanimteyaz/incubator-dubbo that referenced this pull request Jan 18, 2019
apache#3108)

* Refactoring to replace hard coded value with constant and some code optiomization

* Fixed UT failure

* Added review comment by Ian and code4wt
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.

4 participants