Skip to content

Commit

Permalink
Fix NPE in NodeSeenService (#76788) (#76796)
Browse files Browse the repository at this point in the history
This commit adjusts `NodeSeenService` to check if the `NodesShutdownMetadata`
is `null` before trying to work with it. If it is `null`, we can simply
return from the method early as we know there are no shutdowns registered.
  • Loading branch information
gwbrown authored Aug 20, 2021
1 parent 8cc2f3a commit 6ecb8e4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public void clusterChanged(ClusterChangedEvent event) {
}

NodesShutdownMetadata eventShutdownMetadata = event.state().metadata().custom(NodesShutdownMetadata.TYPE);

if (eventShutdownMetadata == null) {
// Since there's no shutdown metadata at all, we know no shutdowns have ever been registered and we can bail.
return;
}

final Set<String> nodesNotPreviouslySeen = eventShutdownMetadata.getAllNodeMetadataMap()
.values()
.stream()
Expand Down

0 comments on commit 6ecb8e4

Please sign in to comment.