From 2abb89dd72a12a207bdf9efdace8cba726b1c088 Mon Sep 17 00:00:00 2001 From: Peter Alfonsi Date: Tue, 23 Apr 2024 16:26:33 -0700 Subject: [PATCH] Addressed comment Signed-off-by: Peter Alfonsi --- .../common/cache/stats/NoopCacheStatsHolder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/cache/stats/NoopCacheStatsHolder.java b/server/src/main/java/org/opensearch/common/cache/stats/NoopCacheStatsHolder.java index 47a4b54ba5f93..b7debbd8a8eab 100644 --- a/server/src/main/java/org/opensearch/common/cache/stats/NoopCacheStatsHolder.java +++ b/server/src/main/java/org/opensearch/common/cache/stats/NoopCacheStatsHolder.java @@ -17,6 +17,11 @@ */ public class NoopCacheStatsHolder implements CacheStatsHolder { private static final NoopCacheStatsHolder singletonInstance = new NoopCacheStatsHolder(); + private static final ImmutableCacheStatsHolder immutableCacheStatsHolder; + static { + ImmutableCacheStatsHolder.Node dummyNode = new ImmutableCacheStatsHolder.Node("", null, new ImmutableCacheStats(0, 0, 0, 0, 0)); + immutableCacheStatsHolder = new ImmutableCacheStatsHolder(dummyNode, List.of()); + } private NoopCacheStatsHolder() {} @@ -58,7 +63,6 @@ public void removeDimensions(List dimensionValues) {} @Override public ImmutableCacheStatsHolder getImmutableCacheStatsHolder() { - ImmutableCacheStatsHolder.Node dummyNode = new ImmutableCacheStatsHolder.Node("", null, new ImmutableCacheStats(0, 0, 0, 0, 0)); - return new ImmutableCacheStatsHolder(dummyNode, List.of()); + return immutableCacheStatsHolder; } }