You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "John-Smile (GitHub)" <gi...@apache.org> on 2019/03/16 17:51:47 UTC

[GitHub] [incubator-dubbo] John-Smile opened pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Fixes #3625

## What is the purpose of the change

Remove magic number 5 in line 70 of org.apache.dubbo.configcenter.support.zookeeper.CacheListener#childEvent.

## Brief changelog

Add constant 'MIN_PATH_ARRAY_LENGTH'

## 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/3680 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] John-Smile closed pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

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

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


[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
I make an experiment.
`
public class Test {
    private static final int CLZ_FIELD = 65535;
    public static void main(String[] args) {
        final int localVariable = 65536;
        System.out.println(localVariable);
        System.out.println(CLZ_FIELD);
    }
}
`
After decompilation, I got
`
  public static void main(java.lang.String[]);
    Code:
       0: ldc           #2                  // int 65536
       2: istore_1
       3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
       6: ldc           #2                  // int 65536
       8: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
      11: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
      14: ldc           #6                  // int 65535
      16: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
      19: return
`
Every time the local constant need one more step ('0: ldc #2') and one more stack space than static constant.
So you are right, I will make it static.

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

[GitHub] [incubator-dubbo] ralf0131 commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
It is better to make it static.

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


[GitHub] [incubator-dubbo] ralf0131 commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
Hi, this change is irrelevant.  And is addressed in #3681 . Please rebase with the master and send the pull request again.

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


[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
I make an experiment.

`
public class Test {
    private static final int CLZ_FIELD = 65535;
    public static void main(String[] args) {
        final int localVariable = 65536;
        System.out.println(localVariable);
        System.out.println(CLZ_FIELD);
    }
}

`

After decompilation, I got

`
public static void main(java.lang.String[]);
  Code:
     0: ldc           #2                  // int 65536
     2: istore_1
     3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
     6: ldc           #2                  // int 65536
     8: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
    11: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
    14: ldc           #6                  // int 65535
    16: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
    19: return
`

Every time the local constant need one more step ('0: ldc #2') and one more stack space than static constant.
So you are right, I will make it static.

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

[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
I make an experiment.

public class Test {
    private static final int CLZ_FIELD = 65535;
    public static void main(String[] args) {
        final int localVariable = 65536;
        System.out.println(localVariable);
        System.out.println(CLZ_FIELD);
    }
}

After decompilation, I got

  public static void main(java.lang.String[]);
    Code:
       0: ldc           #2                  // int 65536
       2: istore_1
       3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
       6: ldc           #2                  // int 65536
       8: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
      11: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
      14: ldc           #6                  // int 65535
      16: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
      19: return

Every time the local constant need one more step ('0: ldc #2') and one more stack space than static constant.
So you are right, I will make it static.

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

[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
I make an experiment.
```
public class Test {
    private static final int CLZ_FIELD = 65535;
    public static void main(String[] args) {
        final int localVariable = 65536;
        System.out.println(localVariable);
        System.out.println(CLZ_FIELD);
    }
}
```
After decompilation, I got
```
public static void main(java.lang.String[]);
  Code:
     0: ldc           #2                  // int 65536
     2: istore_1
     3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
     6: ldc           #2                  // int 65536
     8: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
    11: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
    14: ldc           #6                  // int 65535
    16: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
    19: return
```
Every time the local constant need one more step ('`0: ldc #2`') and one more stack space than static constant.
So you are right, I will make it static.

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

[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
I make an experiment.

```
public class Test {
    private static final int CLZ_FIELD = 65535;
    public static void main(String[] args) {
        final int localVariable = 65536;
        System.out.println(localVariable);
        System.out.println(CLZ_FIELD);
    }
}
```

After decompilation, I got


public static void main(java.lang.String[]);
```
  Code:
     0: ldc           #2                  // int 65536
     2: istore_1
     3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
     6: ldc           #2                  // int 65536
     8: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
    11: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
    14: ldc           #6                  // int 65535
    16: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
    19: return
```

Every time the local constant need one more step ('`0: ldc #2`') and one more stack space than static constant.
So you are right, I will make it static.

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

[GitHub] [incubator-dubbo] codecov-io commented on issue #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

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

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

```diff
@@             Coverage Diff              @@
##             master    #3680      +/-   ##
============================================
- Coverage     63.44%   63.31%   -0.14%     
  Complexity       71       71              
============================================
  Files           703      703              
  Lines         31000    31050      +50     
  Branches       5024     5039      +15     
============================================
- Hits          19669    19659      -10     
- Misses         9066     9122      +56     
- Partials       2265     2269       +4
```


| [Impacted Files](https://codecov.io/gh/apache/incubator-dubbo/pull/3680?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...dubbo/remoting/exchange/support/DefaultFuture.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L0RlZmF1bHRGdXR1cmUuamF2YQ==) | `71.42% <100%> (-4.25%)` | `0 <0> (ø)` | |
| [.../configcenter/support/zookeeper/CacheListener.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tY29uZmlnY2VudGVyL2R1YmJvLWNvbmZpZ2NlbnRlci16b29rZWVwZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL2NvbmZpZ2NlbnRlci9zdXBwb3J0L3pvb2tlZXBlci9DYWNoZUxpc3RlbmVyLmphdmE=) | `63.15% <100%> (+0.99%)` | `0 <0> (ø)` | :arrow_down: |
| [.../apache/dubbo/remoting/transport/AbstractPeer.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy90cmFuc3BvcnQvQWJzdHJhY3RQZWVyLmphdmE=) | `60.86% <0%> (-10.87%)` | `0% <0%> (ø)` | |
| [...mmon/threadpool/support/AbortPolicyWithReport.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vdGhyZWFkcG9vbC9zdXBwb3J0L0Fib3J0UG9saWN5V2l0aFJlcG9ydC5qYXZh) | `83.33% <0%> (-5.56%)` | `0% <0%> (ø)` | |
| [...ng/exchange/support/header/HeartbeatTimerTask.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9leGNoYW5nZS9zdXBwb3J0L2hlYWRlci9IZWFydGJlYXRUaW1lclRhc2suamF2YQ==) | `73.68% <0%> (-5.27%)` | `0% <0%> (ø)` | |
| [...bo/rpc/cluster/support/FailbackClusterInvoker.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tY2x1c3Rlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL2NsdXN0ZXIvc3VwcG9ydC9GYWlsYmFja0NsdXN0ZXJJbnZva2VyLmphdmE=) | `67.21% <0%> (-3.28%)` | `0% <0%> (ø)` | |
| [...a/org/apache/dubbo/registry/etcd/EtcdRegistry.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tcmVnaXN0cnkvZHViYm8tcmVnaXN0cnktZXRjZDMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JlZ2lzdHJ5L2V0Y2QvRXRjZFJlZ2lzdHJ5LmphdmE=) | `0% <0%> (ø)` | `0% <0%> (ø)` | :arrow_down: |
| [...pache/dubbo/remoting/transport/AbstractServer.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy90cmFuc3BvcnQvQWJzdHJhY3RTZXJ2ZXIuamF2YQ==) | `47.91% <0%> (+1.04%)` | `0% <0%> (ø)` | :arrow_down: |
| [...ache/dubbo/remoting/p2p/support/AbstractGroup.java](https://codecov.io/gh/apache/incubator-dubbo/pull/3680/diff?src=pr&el=tree#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctcDJwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy9wMnAvc3VwcG9ydC9BYnN0cmFjdEdyb3VwLmphdmE=) | `56.81% <0%> (+11.36%)` | `0% <0%> (ø)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-dubbo/pull/3680?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/3680?src=pr&el=footer). Last update [b2bfbc7...8eb47c3](https://codecov.io/gh/apache/incubator-dubbo/pull/3680?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/3680 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] ralf0131 commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "ralf0131 (GitHub)" <gi...@apache.org>.
No, it is not. As a local constant, it will be allocated every time the method is invoked. I don't think it should be local. 

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


[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
It is better to be local, because it is only used in one method.

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


[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
I make an experiment.
`public class Test {
    private static final int CLZ_FIELD = 65535;
    public static void main(String[] args) {
        final int localVariable = 65536;
        System.out.println(localVariable);
        System.out.println(CLZ_FIELD);
    }
}`
After decompilation, I got
`  public static void main(java.lang.String[]);
    Code:
       0: ldc           #2                  // int 65536
       2: istore_1
       3: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
       6: ldc           #2                  // int 65536
       8: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
      11: getstatic     #3                  // Field java/lang/System.out:Ljava/io/PrintStream;
      14: ldc           #6                  // int 65535
      16: invokevirtual #4                  // Method java/io/PrintStream.println:(I)V
      19: return`
Every time the local constant need one more step ('0: ldc           #2') and one more stack space than static constant. 
So you are right,  I will make it static.

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

[GitHub] [incubator-dubbo] John-Smile commented on pull request #3680: [Dubbo-3625] Add constant 'MIN_PATH_ARRAY_LENGTH'

Posted by "John-Smile (GitHub)" <gi...@apache.org>.
OK,I will send the pull request again.

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