Repository navigation
[Enhancement]: RestProtocol - #3480
Conversation
- use `Map#computeIfAbsent` to replace check-and-create - use lambdas to replace annonymous inner types
Codecov Report
@@ Coverage Diff @@
## master #3480 +/- ##
============================================
- Coverage 64.1% 64.06% -0.04%
Complexity 71 71
============================================
Files 664 664
Lines 28605 28604 -1
Branches 4769 4768 -1
============================================
- Hits 18338 18326 -12
- Misses 8060 8068 +8
- Partials 2207 2210 +3
Continue to review full report at Codecov.
|
| server.start(url); | ||
| servers.put(addr, server); | ||
| } | ||
| RestServer server = servers.computeIfAbsent(addr, addr0 -> { |
There was a problem hiding this comment.
It is recommended to change addr0 to restServer
There was a problem hiding this comment.
@CrazyHZM please refer to the JavaDoc of computeIfAbsent, note the second parameter.
There was a problem hiding this comment.
Not a grammatical error, just add readability
| server.start(url); | ||
| servers.put(addr, server); | ||
| } | ||
| RestServer server = servers.computeIfAbsent(addr, addr0 -> { |
There was a problem hiding this comment.
I also think we should replace addr0 into restServer. the addr0 is not clear for people to understand.
There was a problem hiding this comment.
but I'm wondering why renaming a variable of type String to restServer increases readability
There was a problem hiding this comment.
This has nothing to do with whether it is a String type, but using restServer in the meaning description will be clearer than addr0.
This is also to let others see the source code, know that the second parameter of the servers is a RestServer type.
There was a problem hiding this comment.
@scxwhite @CrazyHZM Since the changes is controversial, I've reverted the changes, as for
This is also to let others see the source code, know that the second parameter of the
serversis aRestServertype.
I'd rather suggest renaming the servers to something like serversKeyedByAddress or anything else but what you said.
There was a problem hiding this comment.
That part of the code does not need to reverted, I think you modified is good, just change addr0 to restServer
There was a problem hiding this comment.
Changes are made as requested
lixiaojiee
left a comment
There was a problem hiding this comment.
It looks good to me, thank you for your contribution.
Map#computeIfAbsentto replace check-and-createWhat is the purpose of the change
XXXXX
Brief changelog
XXXXX
Verifying this change
XXXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false&mvn clean test-compile failsafe:integration-testto make sure unit-test and integration-test pass.