From 04002d093d5b9391bc4f5ffc9c8639736fd2672f Mon Sep 17 00:00:00 2001 From: David Mollitor Date: Tue, 1 Sep 2026 17:56:51 +0000 Subject: [PATCH] refactor: drop redundant reference check in Labels.isEmpty() The `this == EMPTY` clause is redundant: Labels.equals() already begins with `if (this == o) return true;`, so `this.equals(EMPTY)` covers the singleton case the reference check guards. Removing it is behavior-preserving and also removes the sole reason for the @SuppressWarnings("ReferenceEquality"). Signed-off-by: David Mollitor --- .../java/io/prometheus/metrics/model/snapshots/Labels.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Labels.java b/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Labels.java index d5c0a3a95..deb1c7f94 100644 --- a/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Labels.java +++ b/prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/Labels.java @@ -40,9 +40,8 @@ private Labels(String[] names, String[] prometheusNames, String[] values) { this.values = values; } - @SuppressWarnings("ReferenceEquality") public boolean isEmpty() { - return this == EMPTY || this.equals(EMPTY); + return this.equals(EMPTY); } /**