Remove NPE from IndexFollowingIT (#35717)

Currently there is a common NPE in the IndexFollowingIT that does not
indicate the test failing. This is when a cluster state listener is
called and certain index metadata is not yet available.

This commit checks that the metadata is not null before performing the
logic that depends on the metadata.
This commit is contained in:
Tim Brooks 2018-11-19 20:38:49 -07:00 committed by GitHub
parent d367894c31
commit a989b675b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -807,7 +807,7 @@ public class IndexFollowingIT extends CcrIntegTestCase {
AtomicBoolean closed = new AtomicBoolean(false);
clusterService.addListener(event -> {
IndexMetaData indexMetaData = event.state().metaData().index(indexName);
if (indexMetaData.getState() == IndexMetaData.State.CLOSE) {
if (indexMetaData != null && indexMetaData.getState() == IndexMetaData.State.CLOSE) {
closed.set(true);
}
});