From c1e163417196f91aad9f516514f2954a628c5cf1 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Tue, 5 Nov 2024 10:24:05 -0800 Subject: [PATCH] Clean up doPrivileged calls Signed-off-by: Finn Carroll --- .../index/store/remote/utils/TransferManager.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/store/remote/utils/TransferManager.java b/server/src/main/java/org/opensearch/index/store/remote/utils/TransferManager.java index 8db8cb8057502..911082d36a6e1 100644 --- a/server/src/main/java/org/opensearch/index/store/remote/utils/TransferManager.java +++ b/server/src/main/java/org/opensearch/index/store/remote/utils/TransferManager.java @@ -67,12 +67,11 @@ public TransferManager(final StreamReader streamReader, final FileCache fileCach * @return future of IndexInput augmented with internal caching maintenance tasks */ public IndexInput fetchBlob(BlobFetchRequest blobFetchRequest) throws IOException { - final Path key = blobFetchRequest.getFilePath(); logger.trace("fetchBlob called for {}", key.toString()); - final CachedIndexInput cacheEntry = AccessController.doPrivileged((PrivilegedAction) () -> { - return fileCache.compute(key, (path, cachedIndexInput) -> { + return AccessController.doPrivileged((PrivilegedAction) () -> { + CachedIndexInput cacheEntry = fileCache.compute(key, (path, cachedIndexInput) -> { if (cachedIndexInput == null || cachedIndexInput.isClosed()) { logger.trace("Transfer Manager - IndexInput closed or not in cache"); // Doesn't exist or is closed, either way create a new one @@ -83,9 +82,7 @@ public IndexInput fetchBlob(BlobFetchRequest blobFetchRequest) throws IOExceptio return cachedIndexInput; } }); - }); - return AccessController.doPrivileged((PrivilegedAction) () -> { // Cache entry was either retrieved from the cache or newly added, either // way the reference count has been incremented by one. We can only // decrement this reference _after_ creating the clone to be returned.