From d6b2425771396ef136388131f182d5d131299ed3 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Wed, 13 Nov 2024 15:31:12 +0100 Subject: [PATCH] Fix TranslogDeletionPolicy when assertions are disabled (#116654) (#116714) Current code causes a NPE when assertions are disabled: the openTranslogRef is only non-null when assertions are enabled. Co-authored-by: Elastic Machine --- .../elasticsearch/index/translog/TranslogDeletionPolicy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/index/translog/TranslogDeletionPolicy.java b/server/src/main/java/org/elasticsearch/index/translog/TranslogDeletionPolicy.java index 6ac7313a1c51b..2700cba0abc3c 100644 --- a/server/src/main/java/org/elasticsearch/index/translog/TranslogDeletionPolicy.java +++ b/server/src/main/java/org/elasticsearch/index/translog/TranslogDeletionPolicy.java @@ -24,7 +24,7 @@ public final class TranslogDeletionPolicy { private final Map openTranslogRef; public void assertNoOpenTranslogRefs() { - if (openTranslogRef.isEmpty() == false) { + if (Assertions.ENABLED && openTranslogRef.isEmpty() == false) { AssertionError e = new AssertionError("not all translog generations have been released"); openTranslogRef.values().forEach(e::addSuppressed); throw e;