You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "CrazyHZM (GitHub)" <gi...@apache.org> on 2019/01/03 05:11:07 UTC

[GitHub] [incubator-dubbo] CrazyHZM opened pull request #3118: code optimization

## What 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:

- [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.
- [ ] 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](https://github.com/apache/incubator-dubbo/tree/master/dubbo-test).
- [ ] 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/3118 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
LOCALHOST is good enough, LOCALHOST_VALUE sound extra here. Having said this, it is very minor both should be ok. I leave it to you. If any has any suggestion it can be modified ltr. :)

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
@CrazyHZM 
I think once the **name** is not null the rest of two evaulation 

```
!Constants.ANYHOST_VALUE.equals(name)
                && !Constants.LOCALHOST_VALUE.equals(name)
```

most likely be evaluates to **true** for non localhost so the chances of this whole condition to become true depends on **IP_PATTERN.matcher(name).matches()**.  So from better understanding and performance point of view I think it would be better if we change it to 

```
(name != null
                && IP_PATTERN.matcher(name).matches()
                && !Constants.ANYHOST_VALUE.equals(name)
                && !Constants.LOCALHOST_VALUE.equals(name));
```
What do yu say?

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
I think Constants.LOCALHOST should be good value looks like extra here. What do you say?

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


[GitHub] [incubator-dubbo] codecov-io commented on issue #3118: code optimization

Posted by "codecov-io (GitHub)" <gi...@apache.org>.
# [Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3118?src=pr&el=h1) Report
> Merging [#3118](https://codecov.io/gh/apache/incubator-dubbo/pull/3118?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-dubbo/commit/95ebfe8b5a93942d3c3928ad5e9cd4709c76886a?src=pr&el=desc) will **decrease** coverage by `0.06%`.
> The diff coverage is `44.82%`.

[![Impacted file tree graph](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/graphs/tree.svg?width=650&token=VnEIkiFQT0&height=150&src=pr)](https://codecov.io/gh/apache/incubator-dubbo/pull/3118?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##             master   #3118      +/-   ##
===========================================
- Coverage     63.67%   63.6%   -0.07%     
  Complexity       75      75              
===========================================
  Files           652     652              
  Lines         28190   28196       +6     
  Branches       4784    4784              
===========================================
- Hits          17950   17935      -15     
- Misses         7989    8006      +17     
- Partials       2251    2255       +4
```


| [Impacted Files](https://codecov.io/gh/apache/incubator-dubbo/pull/3118?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...dubbo/metadata/support/AbstractMetadataReport.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tbWV0YWRhdGEtcmVwb3J0L2R1YmJvLW1ldGFkYXRhLXJlcG9ydC1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL21ldGFkYXRhL3N1cHBvcnQvQWJzdHJhY3RNZXRhZGF0YVJlcG9ydC5qYXZh) | `69.35% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...pache/dubbo/rpc/cluster/router/AbstractRouter.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tY2x1c3Rlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL2NsdXN0ZXIvcm91dGVyL0Fic3RyYWN0Um91dGVyLmphdmE=) | `40% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...ing/zookeeper/support/AbstractZookeeperClient.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3Rpbmctem9va2VlcGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy96b29rZWVwZXIvc3VwcG9ydC9BYnN0cmFjdFpvb2tlZXBlckNsaWVudC5qYXZh) | `77.41% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...o/metadata/definition/model/ServiceDefinition.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tbWV0YWRhdGEtcmVwb3J0L2R1YmJvLW1ldGFkYXRhLWRlZmluaXRpb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL21ldGFkYXRhL2RlZmluaXRpb24vbW9kZWwvU2VydmljZURlZmluaXRpb24uamF2YQ==) | `44.82% <0%> (-3.33%)` | `9 <0> (ø)` | |
| [...ubbo/metadata/definition/model/TypeDefinition.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tbWV0YWRhdGEtcmVwb3J0L2R1YmJvLW1ldGFkYXRhLWRlZmluaXRpb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL21ldGFkYXRhL2RlZmluaXRpb24vbW9kZWwvVHlwZURlZmluaXRpb24uamF2YQ==) | `30% <0%> (-1.58%)` | `7 <0> (ø)` | |
| [...bo/metadata/definition/model/MethodDefinition.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tbWV0YWRhdGEtcmVwb3J0L2R1YmJvLW1ldGFkYXRhLWRlZmluaXRpb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL21ldGFkYXRhL2RlZmluaXRpb24vbW9kZWwvTWV0aG9kRGVmaW5pdGlvbi5qYXZh) | `39.28% <0%> (-3.03%)` | `8 <0> (ø)` | |
| [...e/dubbo/rpc/cluster/directory/StaticDirectory.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tY2x1c3Rlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL2NsdXN0ZXIvZGlyZWN0b3J5L1N0YXRpY0RpcmVjdG9yeS5qYXZh) | `66.66% <0%> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [.../apache/dubbo/rpc/protocol/injvm/InjvmInvoker.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tcnBjL2R1YmJvLXJwYy1pbmp2bS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL3Byb3RvY29sL2luanZtL0luanZtSW52b2tlci5qYXZh) | `84.61% <100%> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...n/java/org/apache/dubbo/config/AbstractConfig.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tY29uZmlnL2R1YmJvLWNvbmZpZy1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL2NvbmZpZy9BYnN0cmFjdENvbmZpZy5qYXZh) | `79.09% <100%> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [.../java/org/apache/dubbo/config/ReferenceConfig.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree#diff-ZHViYm8tY29uZmlnL2R1YmJvLWNvbmZpZy1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL2NvbmZpZy9SZWZlcmVuY2VDb25maWcuamF2YQ==) | `58.27% <100%> (-0.76%)` | `0 <0> (ø)` | |
| ... and [16 more](https://codecov.io/gh/apache/incubator-dubbo/pull/3118/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3118?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3118?src=pr&el=footer). Last update [95ebfe8...e4ef2c7](https://codecov.io/gh/apache/incubator-dubbo/pull/3118?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


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

[GitHub] [incubator-dubbo] CrazyHZM commented on pull request #3118: code optimization

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
Increase readability

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


[GitHub] [incubator-dubbo] khanimteyaz commented on issue #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
Looks good to me.

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


[GitHub] [incubator-dubbo] CrazyHZM commented on pull request #3118: code optimization

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
thanks, I think this idea is good. I will modify it.

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


[GitHub] [incubator-dubbo] CrazyHZM commented on pull request #3118: code optimization

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
thanks,I am not sure about this, I feel no difference.

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


[GitHub] [incubator-dubbo] CrazyHZM commented on pull request #3118: code optimization

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
thanks, I think this idea is good. I will modify it.

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
same as above.

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
I would preffer to extract out this to a boolean method with meaningfull name. 
e.g.
   ```
 if (isMetaMethod(method)) {
}
```
```
private boolean isMetaMethod(Method method) {
   String name=method.getName();
   if(!((name.startsWith("get") || name.startsWith("is"))) {
         return false;
   }
    if( !"get".equals(name) && !"getClass".equals(name)) {
        return false;
    }
   if(!Modifier.isPublic(method.getModifiers()) {
      return false;
   }
    if( method.getParameterTypes().length > 0 ) {
       return false;
    }
   if(!ClassHelper.isPrimitive(method.getReturnType())) {
      return false;
   }
   return true;
}
```


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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
Cool.

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
same as above.

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


[GitHub] [incubator-dubbo] CrazyHZM commented on pull request #3118: code optimization

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
`    if( !"get".equals(name) && !"getClass".equals(name)) {
        return false;
    }`
Here is wrong.
I have modified it elsewhere, you can re-examine it.


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


[GitHub] [incubator-dubbo] ralf0131 closed pull request #3118: code optimization

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
[ pull request closed by ralf0131 ]

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
what has been optimize here?

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
I think Constants.LOCALHOST should be good and Constants.LOCALHOST_VALUE looks like extra here. What do you say?

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


[GitHub] [incubator-dubbo] khanimteyaz commented on pull request #3118: code optimization

Posted by "khanimteyaz (GitHub)" <gi...@apache.org>.
same above,.

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