Skip to content

Commit 307a60c

Browse files
committed
avoid instanceof in catch
1 parent 098140e commit 307a60c

File tree

1 file changed

+16
-18
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session

1 file changed

+16
-18
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -755,27 +755,25 @@ private static void analyzeAndMaybeRetry(
755755
EsqlCCSUtils.updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, result.indices, requestFilter != null);
756756
}
757757
plan = analyzeAction.apply(result);
758-
} catch (Exception e) {
759-
if (e instanceof VerificationException ve) {
760-
LOGGER.debug(
761-
"Analyzing the plan ({} attempt, {} filter) failed with {}",
762-
attemptMessage,
763-
filterPresentMessage,
764-
ve.getDetailedMessage()
765-
);
766-
if (requestFilter == null) {
767-
// if the initial request didn't have a filter, then just pass the exception back to the user
768-
logicalPlanListener.onFailure(ve);
769-
} else {
770-
// interested only in a VerificationException, but this time we are taking out the index filter
771-
// to try and make the index resolution work without any index filtering. In the next step... to be continued
772-
l.onResponse(result);
773-
}
758+
} catch (VerificationException ve) {
759+
LOGGER.debug(
760+
"Analyzing the plan ({} attempt, {} filter) failed with {}",
761+
attemptMessage,
762+
filterPresentMessage,
763+
ve.getDetailedMessage()
764+
);
765+
if (requestFilter == null) {
766+
// if the initial request didn't have a filter, then just pass the exception back to the user
767+
logicalPlanListener.onFailure(ve);
774768
} else {
775-
// if the query failed with any other type of exception, then just pass the exception back to the user
776-
logicalPlanListener.onFailure(e);
769+
// interested only in a VerificationException, but this time we are taking out the index filter
770+
// to try and make the index resolution work without any index filtering. In the next step... to be continued
771+
l.onResponse(result);
777772
}
778773
return;
774+
} catch (Exception e) {
775+
logicalPlanListener.onFailure(e);
776+
return;
779777
}
780778
LOGGER.debug("Analyzed plan ({} attempt, {} filter):\n{}", attemptMessage, filterPresentMessage, plan);
781779
// the analysis succeeded from the first attempt, irrespective if it had a filter or not, just continue with the planning

0 commit comments

Comments
 (0)