Skip to content

Commit 3f54a06

Browse files
authored
[Test] Initialize DesiredBalanceMetrics.NOOP after empty allocation stats (#134270)
To avoid NPE.
1 parent 66d1a8e commit 3f54a06

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceMetrics.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
*/
3434
public class DesiredBalanceMetrics {
3535

36-
public static DesiredBalanceMetrics NOOP = new DesiredBalanceMetrics(MeterRegistry.NOOP);
37-
3836
/**
3937
* @param unassignedShards Shards that are not assigned to any node.
4038
* @param allocationStatsByRole A breakdown of the allocations stats by {@link ShardRouting.Role}
@@ -132,6 +130,7 @@ public record NodeWeightStats(long shardCount, double diskUsageInBytes, double w
132130
public static final String WRITE_LOAD_DECIDER_MAX_LATENCY_VALUE = "es.allocator.deciders.write_load.max_latency_value.current";
133131

134132
public static final AllocationStats EMPTY_ALLOCATION_STATS = new AllocationStats(0, Map.of());
133+
public static final DesiredBalanceMetrics NOOP = new DesiredBalanceMetrics(MeterRegistry.NOOP);
135134

136135
private final MeterRegistry meterRegistry;
137136
private volatile boolean nodeIsMaster = false;

0 commit comments

Comments
 (0)