@@ -227,25 +227,17 @@ private void runCoordinatorRewritePhase() {
227227 }
228228
229229 private void consumeResult (boolean canMatch , ShardSearchRequest request ) {
230- CanMatchShardResponse result = new CanMatchShardResponse (canMatch , null );
231- result .setShardIndex (request .shardRequestIndex ());
232- consumeResult (request .shardRequestIndex (), result );
230+ consumeResult (request .shardRequestIndex (), canMatch , null );
233231 }
234232
235- private void consumeResult (int index , CanMatchShardResponse result ) {
236- final boolean canMatch = result .canMatch ();
237- final MinAndMax <?> minAndMax = result .estimatedMinAndMax ();
238- if (canMatch || minAndMax != null ) {
239- consumeResult (index , canMatch , minAndMax );
240- }
241- }
242-
243- private synchronized void consumeResult (int shardIndex , boolean canMatch , MinAndMax <?> minAndMax ) {
233+ private void consumeResult (int shardIndex , boolean canMatch , MinAndMax <?> minAndMax ) {
244234 if (canMatch ) {
245- possibleMatches .set (shardIndex );
246- numPossibleMatches ++;
235+ synchronized (this ) {
236+ possibleMatches .set (shardIndex );
237+ numPossibleMatches ++;
238+ minAndMaxes [shardIndex ] = minAndMax ;
239+ }
247240 }
248- minAndMaxes [shardIndex ] = minAndMax ;
249241 }
250242
251243 private void checkNoMissingShards (List <SearchShardIterator > shards ) {
@@ -347,7 +339,7 @@ private void onAllFailed(List<CanMatchNodeRequest.Shard> shardLevelRequests) {
347339
348340 private void onOperation (int idx , CanMatchShardResponse response ) {
349341 failedResponses .remove (idx );
350- consumeResult (idx , response );
342+ consumeResult (idx , response . canMatch (), response . estimatedMinAndMax () );
351343 if (countDown .countDown ()) {
352344 finishRound ();
353345 }
0 commit comments