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
         Environment:  
{code:java}
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:java}
// code placeholder
if (leaderServer == null) {
   LOG.warn("Couldn't find the leader with id = " + current.getId());
}
return leaderServer;
{code}
caller  Observer#observeLeader and Follower#followLeader will directly use return value
w/o null check:
{code:java}
//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);
}{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message