diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a0def2bf168b..b814f2bc7057f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [Java Agent] Allow JRT protocol URLs in protection domain extraction ([#19683](https://github.com/opensearch-project/OpenSearch/pull/19683)) - Fix potential concurrent modification exception when updating allocation filters ([#19701])(https://github.com/opensearch-project/OpenSearch/pull/19701)) - Fix file-based ingestion consumer to handle start point beyond max line number([#19757])(https://github.com/opensearch-project/OpenSearch/pull/19757)) +- Fixed assertion unsafe use of ClusterService.state() in ResourceUsageCollectorService ([#19775])(https://github.com/opensearch-project/OpenSearch/pull/19775)) ### Dependencies - Update to Gradle 9.1 ([#19575](https://github.com/opensearch-project/OpenSearch/pull/19575)) diff --git a/server/src/main/java/org/opensearch/node/ResourceUsageCollectorService.java b/server/src/main/java/org/opensearch/node/ResourceUsageCollectorService.java index ecd2a5615e1fe..5cf396a76edb6 100644 --- a/server/src/main/java/org/opensearch/node/ResourceUsageCollectorService.java +++ b/server/src/main/java/org/opensearch/node/ResourceUsageCollectorService.java @@ -126,7 +126,7 @@ public NodesResourceUsageStats stats() { * Fetch local node resource usage statistics and add it to store along with the current timestamp */ private void collectLocalNodeResourceUsageStats() { - if (nodeResourceUsageTracker.isReady() && clusterService.state() != null) { + if (nodeResourceUsageTracker.isReady() && clusterService.isStateInitialised()) { collectNodeResourceUsageStats( clusterService.state().nodes().getLocalNodeId(), System.currentTimeMillis(),