From aba358aa763cdc00b613a42d13c908c5ab285782 Mon Sep 17 00:00:00 2001 From: Henning Andersen Date: Thu, 25 Jan 2024 12:20:27 +0100 Subject: [PATCH] Fix order of incref/ensureopen --- .../elasticsearch/blobcache/shared/SharedBlobCacheService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java b/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java index 68a13125eba3..bd7537aabdcc 100644 --- a/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java +++ b/x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java @@ -860,11 +860,11 @@ private AbstractRunnable fillGapRunnable(CacheFileRegion cacheFileRegion, RangeM return new AbstractRunnable() { @Override protected void doRun() throws Exception { - ensureOpen(); if (cacheFileRegion.tryIncRef() == false) { throw new AlreadyClosedException("File chunk [" + cacheFileRegion.regionKey + "] has been released"); } try { + ensureOpen(); final int start = Math.toIntExact(gap.start()); var ioRef = io; assert regionOwners.get(ioRef) == cacheFileRegion;