Skip to content

Commit 36c2e8e

Browse files
committed
Use a final array as a mutable box
1 parent 72ff3c0 commit 36c2e8e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/DocumentSubsetBitsetCache.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import java.util.concurrent.ExecutionException;
5252
import java.util.concurrent.ExecutorService;
5353
import java.util.concurrent.TimeUnit;
54-
import java.util.concurrent.atomic.AtomicBoolean;
5554
import java.util.concurrent.atomic.AtomicLong;
5655
import java.util.concurrent.atomic.LongAdder;
5756
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -250,9 +249,9 @@ public BitSet getBitSet(final Query query, final LeafReaderContext context) thro
250249
final BitsetCacheKey cacheKey = new BitsetCacheKey(indexKey, query);
251250

252251
try (ReleasableLock ignored = cacheModificationLock.acquire()) {
253-
final AtomicBoolean cacheKeyWasPresent = new AtomicBoolean(true);
252+
final boolean[] cacheKeyWasPresent = new boolean[] { true };
254253
final BitSet bitSet = bitsetCache.computeIfAbsent(cacheKey, ignore1 -> {
255-
cacheKeyWasPresent.set(false);
254+
cacheKeyWasPresent[0] = false;
256255
// This ensures all insertions into the set are guarded by ConcurrentHashMap's atomicity guarantees.
257256
keysByIndex.compute(indexKey, (ignore2, set) -> {
258257
if (set == null) {
@@ -281,7 +280,7 @@ public BitSet getBitSet(final Query query, final LeafReaderContext context) thro
281280
}
282281
return result;
283282
});
284-
if (cacheKeyWasPresent.get()) {
283+
if (cacheKeyWasPresent[0]) {
285284
hitsTimeInNanos.add(relativeNanoTimeProvider.getAsLong() - cacheStart);
286285
} else {
287286
missesTimeInNanos.add(relativeNanoTimeProvider.getAsLong() - cacheStart);

0 commit comments

Comments
 (0)