@@ -379,38 +379,43 @@ private <R extends ActionResponse> void doExecuteForked(
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 */
382- CountDown countDownResponses = new CountDown ( remoteClusterIndices . size ()) ;
382+ Runnable crossProjectReconciler ;
383383 Map <String , ResolvedIndexExpressions > linkedProjectsResponses = ConcurrentCollections .newConcurrentMap ();
384- Runnable crossProjectReconciler = () -> {
385- if (countDownResponses .countDown () && crossProjectEnabled ) {
386- /*
387- * This happens when one or more linked projects respond with an error instead of a valid response -- say, networking
388- * error.
389- */
390- if (linkedProjectsResponses .size () != remoteClusterIndices .size ()) {
391- listener .onFailure (
392- new IllegalArgumentException (
393- "Invalid number of responses received: "
394- + linkedProjectsResponses .size ()
395- + " vs expected "
396- + remoteClusterIndices .size ()
397- )
398- );
399- return ;
400- }
384+ if (remoteClusterIndices .size () > 0 ) {
385+ CountDown countDownResponses = new CountDown (remoteClusterIndices .size ());
386+ crossProjectReconciler = () -> {
387+ if (countDownResponses .countDown () && crossProjectEnabled ) {
388+ /*
389+ * This happens when one or more linked projects respond with an error instead of a valid response -- say
390+ * networking error.
391+ */
392+ if (linkedProjectsResponses .size () != remoteClusterIndices .size ()) {
393+ listener .onFailure (
394+ new IllegalArgumentException (
395+ "Invalid number of responses received: "
396+ + linkedProjectsResponses .size ()
397+ + " vs expected "
398+ + remoteClusterIndices .size ()
399+ )
400+ );
401+ return ;
402+ }
401403
402- Exception validationEx = CrossProjectIndexResolutionValidator .validate (
403- request .indicesOptions (),
404- null ,
405- request .getResolvedIndexExpressions (),
406- linkedProjectsResponses
407- );
404+ Exception validationEx = CrossProjectIndexResolutionValidator .validate (
405+ request .indicesOptions (),
406+ null ,
407+ request .getResolvedIndexExpressions (),
408+ linkedProjectsResponses
409+ );
408410
409- if (validationEx != null ) {
410- listener .onFailure (validationEx );
411+ if (validationEx != null ) {
412+ listener .onFailure (validationEx );
413+ }
411414 }
412- }
413- };
415+ };
416+ } else {
417+ crossProjectReconciler = () -> {};
418+ }
414419
415420 // this is the cross cluster part of this API - we force the other cluster to not merge the results but instead
416421 // send us back all individual index results.
@@ -631,6 +636,7 @@ private static void mergeIndexResponses(
631636 .withResolvedRemotelyBuilder (resolvedRemotely )
632637 .withMinTransportVersion (minTransportVersion .get ())
633638 .withFailures (failures )
639+ .withResolvedIndexExpressions (request .getResolvedIndexExpressions ())
634640 .build ()
635641 );
636642 }
0 commit comments