You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by brettKK <gi...@git.apache.org> on 2018/04/22 07:23:27 UTC

[GitHub] zookeeper pull request #504: Potential NPE in Observer#observeLeader and Fol...

GitHub user brettKK opened a pull request:

    https://github.com/apache/zookeeper/pull/504

    Potential NPE in Observer#observeLeader and Follower#followLeader

    Bug description:
    
    callee Learner#findLeader will return null and callee developer check it but just log:
    ```
    // code placeholder
    if (leaderServer == null) {
       LOG.warn("Couldn't find the leader with id = " + current.getId());
    }
    return leaderServer;
    ```
    
    caller  Observer#observeLeader and Follower#followLeader will directly use return value w/o null check:
    ```
    //Follower#followLeader
    QuorumServer leaderServer = findLeader();
    try {
        connectToLeader(leaderServer.addr, leaderServer.hostname);
        ..........
    }
    //Observer#observeLeader
    QuorumServer leaderServer = findLeader();
    LOG.info("Observing " + leaderServer.addr);
    try {
        connectToLeader(leaderServer.addr, leaderServer.hostname);
    }
    ```
    
    https://issues.apache.org/jira/browse/ZOOKEEPER-3010

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/brettKK/zookeeper ZOOK-3010

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/zookeeper/pull/504.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #504
    
----
commit 7d8d5230c5a87faef94d038a258b159a322f3f5e
Author: gongleigl.gong <go...@...>
Date:   2018-03-26T13:16:06Z

    d

commit 700dfb7f48f774dd215e5bf19340a4b61eda3397
Author: gongleigl.gong <go...@...>
Date:   2018-03-27T16:38:28Z

    fix NPE bug

commit f71d8ce153d393dc3ab13c62d9d374e8a4aeb1cf
Author: brettkk <10...@...>
Date:   2018-04-22T07:19:21Z

    zook3010

----


---

[GitHub] zookeeper issue #504: Potential NPE in Observer#observeLeader and Follower#f...

Posted by lvfangmin <gi...@git.apache.org>.
Github user lvfangmin commented on the issue:

    https://github.com/apache/zookeeper/pull/504
  
    The newly added exception will be caught in the QuorumPeer, which will trigger another round of look up.
    
    This change looks good to me, it’s always safer to check, although this may not actually happen on 3.6 with dynamic config, unless there is a bug, which we should fix.
    
    +1


---