Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaClient leader election isLeader method NPE #2798

Merged
merged 3 commits into from
May 7, 2024

Conversation

GrantPSpencer
Copy link
Contributor

Issues

  • 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

  • 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

  • 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":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. 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)

Copy link
Contributor

@desaikomal desaikomal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect.. thanks

Copy link
Contributor

@xyuanlu xyuanlu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@GrantPSpencer
Copy link
Contributor Author

Pull request approved by @xyuanlu , @desaikomal , @MarkGaox
Commit message: Prevent MetaClient LeaderElectionClient isLeader NPE before joining pool

@xyuanlu xyuanlu merged commit 1bfed31 into apache:master May 7, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants