Skip to content

[globalindex] Fix NPE in SortedFileMetaSelector when index contains empty string key#8312

Open
weibangpeng wants to merge 1 commit into
apache:masterfrom
weibangpeng:fix-7811-npe-sorted-file-meta-selector
Open

[globalindex] Fix NPE in SortedFileMetaSelector when index contains empty string key#8312
weibangpeng wants to merge 1 commit into
apache:masterfrom
weibangpeng:fix-7811-npe-sorted-file-meta-selector

Conversation

@weibangpeng

Copy link
Copy Markdown
Contributor

Summary

Fix NullPointerException when using btree global index on STRING columns with empty string keys.

Root cause

When SortedIndexFileMeta.firstKey() or lastKey() returns null (from null-flagged index file metadata), compareFirstKey/compareLastKey/overlaps passes null to deserialize(), causing NPE.

Fix

Add null guards:

  • compareFirstKey: return -1 for null firstKey (no lower bound)
  • compareLastKey: return 1 for null lastKey (no upper bound)
  • overlaps: skip comparison when key is null

Test

Added testEmptyStringKeyDoesNotThrowNPE covering visitEqual, visitLessThan, visitGreaterThan, visitIn, and visitBetween.

Closes #7811

…mpty string key

Add null checks for firstKey/lastKey in compareFirstKey, compareLastKey,
and overlaps methods to handle null key boundaries gracefully instead of
throwing NullPointerException.

Closes apache#7811
@weibangpeng weibangpeng force-pushed the fix-7811-npe-sorted-file-meta-selector branch from 50d6f01 to 57d1061 Compare June 21, 2026 16:41
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.

[Bug] NPE in BTreeFileMetaSelector when btree global index contains empty string key

1 participant