[x] My PR addresses the following Helix issues and references them in the PR description:
LeaderElectionClient throws NPE if isLeader() is called before client joins leader election participant pool
Caused by: java.lang.NullPointerException
at org.apache.helix.metaclient.recipes.leaderelection.LeaderElectionClient.isLeader(LeaderElectionClient.java:124) ~[org.apache.helix.meta-client-1.3.2.jar:?]
Description
[x] Here are some details about my PR, including screenshots of any UI changes:
Add null pointer check to isLeader() method. isLeader() will now return false when isLeader() is called before the client joins the leader election participant pool.
Added test to assert NPE no longer thrown and that isLeader() returns false in above scenario.
Tests
[x] The following tests are written for this issue:
testIsLeaderBeforeJoiningParticipantPool in TestLeaderElection.java
Changes that Break Backward Compatibility (Optional)
My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
N/A, no backwards incompatibilities
Commits
My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
Subject is separated from body by a blank line
Subject is limited to 50 characters (not including Jira issue reference)
Subject does not end with a period
Subject uses the imperative mood ("add", not "adding")
Body wraps at 72 characters
Body explains "what" and "why", not "how"
Code Quality
My diff has been formatted using helix-style.xml
(helix-style-intellij.xml if IntelliJ IDE is used)
Issues
Description
Add null pointer check to isLeader() method. isLeader() will now return false when isLeader() is called before the client joins the leader election participant pool. Added test to assert NPE no longer thrown and that isLeader() returns false in above scenario.
Tests
testIsLeaderBeforeJoiningParticipantPool in TestLeaderElection.java
Changes that Break Backward Compatibility (Optional)
Commits
Code Quality