Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix null pointer exception during preview #74

Merged
merged 1 commit into from
Mar 24, 2020

Conversation

kaituo
Copy link
Member

@kaituo kaituo commented Mar 23, 2020

Issue #, if available:
#73

Description of changes:
Recently, we changed the anomaly result index’s schema and toXContent method by introducing new fields. During the preview, some of the fields in anomaly result index are null. Thus, toXContent fails with a null pointer exception.

This PR fixes the issue by protecting a field’s serialization with a null check.

This PR also removes an unused local variable in ModelManager.

Testing done:

  • Manually verified the issue is gone
  • gradle build

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Recently, we changed the anomaly result index’s schema and toXContent method by introducing a few fields. During the preview, some of the fields in anomaly result index can be null. Thus, toXContent can fail with a null pointer exception.

This PR fixes the issue by protecting a field’s serialization with a null check.

Testing done:
- Manually verified the issue is gone
- gradle build
@kaituo kaituo self-assigned this Mar 23, 2020
@kaituo kaituo changed the title Fix that preview exits with null pointer exception Fix null pointer exception during preview Mar 23, 2020
Copy link
Contributor

@wnbts wnbts left a comment

Choose a reason for hiding this comment

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

unit tests can be used to prevent regressions.

@kaituo
Copy link
Member Author

kaituo commented Mar 24, 2020

unit tests can be used to prevent regressions.

We may need integration test to find these errors as this requires basically all of the preview components to run to expose this bug. Will create integration test in this package later.

@kaituo kaituo merged commit 7534c89 into opendistro-for-elasticsearch:development Mar 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants