zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nkal...@apache.org
Subject [zookeeper] branch master updated: ZOOKEEPER-3662: Remove NPE Possibility in Follower Class
Date Tue, 03 Nov 2020 16:02:11 GMT
This is an automated email from the ASF dual-hosted git repository.

nkalmar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b034a4  ZOOKEEPER-3662: Remove NPE Possibility in Follower Class
5b034a4 is described below

commit 5b034a4362e41a62da43979ad0fb6c97477c1624
Author: David Mollitor <dmollitor@apache.org>
AuthorDate: Tue Nov 3 17:01:59 2020 +0100

    ZOOKEEPER-3662: Remove NPE Possibility in Follower Class
    
    Author: David Mollitor <dmollitor@apache.org>
    
    Reviewers: Allan Lyu <fangmin@apache.org>, Enrico Olivelli <eolivelli@apache.org>,
Norbert Kalmar <nkalmar@apache.org>
    
    Closes #1192 from belugabehr/ZOOKEEPER-3662
---
 .../org/apache/zookeeper/server/quorum/Follower.java     | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Follower.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Follower.java
index 9420fc3..971710c 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Follower.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Follower.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Objects;
 import org.apache.jute.Record;
 import org.apache.zookeeper.ZooDefs.OpCode;
 import org.apache.zookeeper.common.Time;
@@ -48,10 +49,10 @@ public class Follower extends Learner {
 
     ObserverMaster om;
 
-    Follower(QuorumPeer self, FollowerZooKeeperServer zk) {
-        this.self = self;
+    Follower(final QuorumPeer self, final FollowerZooKeeperServer zk) {
+        this.self = Objects.requireNonNull(self);
+        this.fzk = Objects.requireNonNull(zk);
         this.zk = zk;
-        this.fzk = zk;
     }
 
     @Override
@@ -253,14 +254,9 @@ public class Follower extends Learner {
      * @return zxid
      */
     public long getZxid() {
-        try {
-            synchronized (fzk) {
-                return fzk.getZxid();
-            }
-        } catch (NullPointerException e) {
-            LOG.warn("error getting zxid", e);
+        synchronized (fzk) {
+            return fzk.getZxid();
         }
-        return -1;
     }
 
     /**


Mime
View raw message