From c61cbe683b9c35722642e88686cad0b9f1a52055 Mon Sep 17 00:00:00 2001 From: Valera V Harseko Date: Wed, 8 Jul 2026 17:54:48 +0300 Subject: [PATCH] Use short-circuit && in Exchange.removeKeyRangeInternal (CodeQL java/non-short-circuit-evaluation) The anti-value guard combined removeOnlyAntiValue with the isKeyRangeAntiValue check using the non-short-circuit & operator, so isKeyRangeAntiValue was always evaluated even when removeOnlyAntiValue was false. isKeyRangeAntiValue only reads buffer state and has no side effects, so switching to && is behaviour-preserving and skips the redundant call when the flag is already false. --- persistit/core/src/main/java/com/persistit/Exchange.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistit/core/src/main/java/com/persistit/Exchange.java b/persistit/core/src/main/java/com/persistit/Exchange.java index 3842f42e9..343d84ddf 100644 --- a/persistit/core/src/main/java/com/persistit/Exchange.java +++ b/persistit/core/src/main/java/com/persistit/Exchange.java @@ -3661,7 +3661,7 @@ boolean raw_removeKeyRangeInternal(final Key key1, final Key key2, final boolean LevelCache lc = _levelCache[0]; if (removeOnlyAntiValue - & !isKeyRangeAntiValue(lc._leftBuffer, lc._leftFoundAt, lc._rightBuffer, lc._rightFoundAt)) { + && !isKeyRangeAntiValue(lc._leftBuffer, lc._leftFoundAt, lc._rightBuffer, lc._rightFoundAt)) { result = false; break; }