zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brettKK <...@git.apache.org>
Subject [GitHub] zookeeper pull request #504: Potential NPE in Observer#observeLeader and Fol...
Date Sun, 22 Apr 2018 07:23:27 GMT
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 <gongleigl.gong@...>
Date:   2018-03-26T13:16:06Z

    d

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

    fix NPE bug

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

    zook3010

----


---

Mime
View raw message