Skip to content

Fix NPE in HelixHelper.getOfflineInstanceFromExternalView when ExternalView is null#18455

Merged
yashmayya merged 1 commit into
apache:masterfrom
Akanksha-kedia:fix-helix-helper-null-check
May 11, 2026
Merged

Fix NPE in HelixHelper.getOfflineInstanceFromExternalView when ExternalView is null#18455
yashmayya merged 1 commit into
apache:masterfrom
Akanksha-kedia:fix-helix-helper-null-check

Conversation

@Akanksha-kedia
Copy link
Copy Markdown
Contributor

Summary

getOfflineInstanceFromExternalView() iterates directly over resourceExternalView.getPartitionSet() without a null guard. Passing a null ExternalView (e.g. when the resource has not yet been created in Helix) throws a NullPointerException.

The sibling method getOnlineInstanceFromExternalView() already has the correct null guard:

if (resourceExternalView != null) { ... }

This PR applies the same pattern to getOfflineInstanceFromExternalView() so both methods are consistent and callers get an empty set instead of an NPE.

Test plan

  • Existing unit tests pass
  • Passing null returns an empty set (matches getOnlineInstanceFromExternalView behaviour)

…ceExternalView is null

The sibling method getOnlineInstanceFromExternalView already guards against a null
ExternalView; apply the same null check to getOfflineInstanceFromExternalView so both
methods are consistent and callers that pass a null view (e.g. when the resource is
not yet created) get an empty set instead of a NullPointerException.
@Akanksha-kedia
Copy link
Copy Markdown
Contributor Author

@xiangfu0

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.65%. Comparing base (1881884) to head (ca50f71).
⚠️ Report is 76 commits behind head on master.

Files with missing lines Patch % Lines
...g/apache/pinot/common/utils/helix/HelixHelper.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18455      +/-   ##
============================================
+ Coverage     63.40%   63.65%   +0.24%     
- Complexity     1679     1684       +5     
============================================
  Files          3253     3256       +3     
  Lines        198767   199549     +782     
  Branches      30791    30987     +196     
============================================
+ Hits         126034   127013     +979     
+ Misses        62659    62402     -257     
- Partials      10074    10134      +60     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (?)
java-21 63.65% <0.00%> (+0.24%) ⬆️
temurin 63.65% <0.00%> (+0.24%) ⬆️
unittests 63.64% <0.00%> (+0.24%) ⬆️
unittests1 55.70% <0.00%> (+0.34%) ⬆️
unittests2 34.99% <0.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@yashmayya yashmayya left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@yashmayya yashmayya merged commit 782c83d into apache:master May 11, 2026
15 of 16 checks passed
@Jackie-Jiang
Copy link
Copy Markdown
Contributor

Out of curiosity, how do you use this method? Seems it is not used in the code base

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants