Skip to content

InDimFilter: Fix NPE involving certain Set types.#11169

Merged
gianm merged 3 commits intoapache:masterfrom
gianm:fix-in-filter-set-type
Apr 28, 2021
Merged

InDimFilter: Fix NPE involving certain Set types.#11169
gianm merged 3 commits intoapache:masterfrom
gianm:fix-in-filter-set-type

Conversation

@gianm
Copy link
Contributor

@gianm gianm commented Apr 27, 2021

Normally, InDimFilters that come from JSON have HashSets for "values".
However, programmatically-generated filters (like the ones from #11068)
may use other set types. Some set types, like TreeSets with natural
ordering, will throw NPE on "contains(null)", which causes the
InDimFilter's ValueMatcher to throw NPE if it encounters a null value.

This patch adds code to detect if the values set can support
contains(null), and if not, wrap that in a null-checking lambda.

Also included:

  • Remove unneeded NullHandling.needsEmptyToNull method.
  • Update IndexedTableJoinable to generate a TreeSet that does not
    require lambda-wrapping. (This particular TreeSet is how I noticed
    the bug in the first place.)

Normally, InDimFilters that come from JSON have HashSets for "values".
However, programmatically-generated filters (like the ones from apache#11068)
may use other set types. Some set types, like TreeSets with natural
ordering, will throw NPE on "contains(null)", which causes the
InDimFilter's ValueMatcher to throw NPE if it encounters a null value.

This patch adds code to detect if the values set can support
contains(null), and if not, wrap that in a null-checking lambda.

Also included:

- Remove unneeded NullHandling.needsEmptyToNull method.
- Update IndexedTableJoinable to generate a TreeSet that does not
  require lambda-wrapping. (This particular TreeSet is how I noticed
  the bug in the first place.)
Copy link
Member

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

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

👍

@gianm gianm merged commit ad028de into apache:master Apr 28, 2021
@gianm gianm deleted the fix-in-filter-set-type branch April 28, 2021 21:13
@clintropolis clintropolis added this to the 0.22.0 milestone Aug 12, 2021
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.

2 participants