Skip to content

Commit 72916cf

Browse files
Modify guard clause
1 parent 31ea368 commit 72916cf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/src/main/java/org/elasticsearch/action/fieldcaps/TransportFieldCapabilitiesAction.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,18 @@ private <R extends ActionResponse> void doExecuteForked(
374374
requestDispatcher.execute();
375375

376376
/*
377-
* We need to run the Cross Project Search reconciliation but only after we're heard back from all the linked projects.
377+
* We need to run the Cross Project Search reconciliation but only after we've heard back from all the linked projects.
378378
* It is also possible that some linked projects may respond back with an error instead of a valid response. To facilitate
379379
* this, we use `CountDown` and track each response, irrespective of whether it's valid or not, and then perform the
380380
* reconciliation when it has counted down and the request is a resolvable CPS request.
381381
*/
382382
Runnable crossProjectReconciler;
383383
Map<String, ResolvedIndexExpressions> linkedProjectsResponses = ConcurrentCollections.newConcurrentMap();
384-
if (remoteClusterIndices.size() > 0) {
384+
// Run the reconciler only if there are linked projects and CPS is enabled.
385+
if (remoteClusterIndices.isEmpty() == false && crossProjectEnabled) {
385386
CountDown countDownResponses = new CountDown(remoteClusterIndices.size());
386387
crossProjectReconciler = () -> {
387-
if (countDownResponses.countDown() && crossProjectEnabled) {
388+
if (countDownResponses.countDown()) {
388389
/*
389390
* This happens when one or more linked projects respond with an error instead of a valid response -- say
390391
* networking error.

0 commit comments

Comments
 (0)