-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Bug Fix: Fix text structure NPE when fields have null value #125922
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
Conversation
Pinging @elastic/ml-core (Team:ML) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -425,7 +425,10 @@ static Tuple<Map<String, String>, FieldStats> guessMappingAndCalculateFieldStats | |||
); | |||
} | |||
|
|||
Collection<String> fieldValuesAsStrings = fieldValues.stream().map(Object::toString).collect(Collectors.toList()); | |||
Collection<String> fieldValuesAsStrings = fieldValues.stream() | |||
.filter(value -> value != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter(value -> value != null) | |
.filter(Objects::nonNull) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Here is a example:
it will see the error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for adding the test case and the example for reproducing the error.
null values are filtered out here, I can't see a code path where fieldValues could contain a null.
I understand now the null check is in the list not the contents of the list and that was causing the problem. Thanks for the fix.
@elasticmachine test this please |
@elasticmachine test this please |
) (#127507) Co-authored-by: weizijun <[email protected]>
) (#127505) Co-authored-by: weizijun <[email protected]>
) (#127506) Co-authored-by: weizijun <[email protected]>
) (#127508) Co-authored-by: weizijun <[email protected]>
when fields have null value, Elasticsearch will return NPE.
I add a check to avoid it.