You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2020/11/25 00:59:38 UTC
[incubator-ratis] branch master updated: RATIS-1177. NPE when
RaftServerJmxAdapter queries getLeaderId. (#297)
This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 3b8f66d RATIS-1177. NPE when RaftServerJmxAdapter queries getLeaderId. (#297)
3b8f66d is described below
commit 3b8f66d339f90be9be27ff358af90d17962e0a68
Author: Hanisha Koneru <ha...@apache.org>
AuthorDate: Tue Nov 24 16:59:29 2020 -0800
RATIS-1177. NPE when RaftServerJmxAdapter queries getLeaderId. (#297)
---
.../src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index efe0aa8..73ad4fc 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -1622,7 +1622,12 @@ public class RaftServerImpl implements RaftServer.Division,
@Override
public String getLeaderId() {
- return getState().getLeaderId().toString();
+ RaftPeerId leaderId = getState().getLeaderId();
+ if (leaderId != null) {
+ return leaderId.toString();
+ } else {
+ return null;
+ }
}
@Override