From d140044dc2dbe31bb1fee20ae97e5b9587dfd40b Mon Sep 17 00:00:00 2001 From: Dmitry Kryukov Date: Fri, 23 Aug 2024 19:01:20 +0300 Subject: [PATCH] Fixed assignment to catch block parameter Signed-off-by: Dmitry Kryukov --- .../java/org/opensearch/search/SearchService.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/SearchService.java b/server/src/main/java/org/opensearch/search/SearchService.java index a53a7198c366f..8098d01f46931 100644 --- a/server/src/main/java/org/opensearch/search/SearchService.java +++ b/server/src/main/java/org/opensearch/search/SearchService.java @@ -680,14 +680,15 @@ private SearchPhaseResult executeQueryPhase(ShardSearchRequest request, SearchSh } } catch (Exception e) { // execution exception can happen while loading the cache, strip it - if (e instanceof ExecutionException) { - e = (e.getCause() == null || e.getCause() instanceof Exception) - ? (Exception) e.getCause() - : new OpenSearchException(e.getCause()); + Exception exception = e; + if (exception instanceof ExecutionException) { + exception = (exception.getCause() == null || exception.getCause() instanceof Exception) + ? (Exception) exception.getCause() + : new OpenSearchException(exception.getCause()); } - logger.trace("Query phase failed", e); - processFailure(readerContext, e); - throw e; + logger.trace("Query phase failed", exception); + processFailure(readerContext, exception); + throw exception; } finally { taskResourceTrackingService.writeTaskResourceUsage(task, clusterService.localNode().getId()); }