zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "lujie (JIRA)" <j...@apache.org>
Subject [jira] [Created] (ZOOKEEPER-3010) Potential NPE in Observer#observeLeader and Follower#followLeader
Date Mon, 26 Mar 2018 08:10:00 GMT
lujie created ZOOKEEPER-3010:

             Summary: Potential NPE in Observer#observeLeader and Follower#followLeader
                 Key: ZOOKEEPER-3010
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3010
             Project: ZooKeeper
          Issue Type: Bug
    Affects Versions: 3.6.0
static code analysis{code}

            Reporter: lujie

After ZK-3006 , I develop a very simple static analysis tool to find other Potential NPE
like ZK-3006, this bug is found by this tool and  carefully studied by myself, hopefully
someone can confirm it.
h2. 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:
QuorumServer leaderServer = findLeader();
try {
    connectToLeader(leaderServer.addr, leaderServer.hostname);
QuorumServer leaderServer = findLeader();
LOG.info("Observing " + leaderServer.addr);
try {
    connectToLeader(leaderServer.addr, leaderServer.hostname);

This message was sent by Atlassian JIRA

View raw message