2121import org .elasticsearch .client .internal .OriginSettingClient ;
2222import org .elasticsearch .client .internal .node .NodeClient ;
2323import org .elasticsearch .cluster .node .DiscoveryNode ;
24+ import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
2425import org .elasticsearch .common .io .stream .StreamInput ;
2526import org .elasticsearch .common .io .stream .StreamOutput ;
2627import org .elasticsearch .common .io .stream .Writeable ;
@@ -384,7 +385,11 @@ public void writeTo(StreamOutput out) throws IOException {
384385 }
385386 }
386387
387- public static void registerRequestHandler (TransportService transportService , SearchService searchService ) {
388+ public static void registerRequestHandler (
389+ TransportService transportService ,
390+ SearchService searchService ,
391+ NamedWriteableRegistry namedWriteableRegistry
392+ ) {
388393 final TransportRequestHandler <ScrollFreeContextRequest > freeContextHandler = (request , channel , task ) -> {
389394 logger .trace ("releasing search context [{}]" , request .id ());
390395 boolean freed = searchService .freeReaderContext (request .id ());
@@ -401,7 +406,8 @@ public static void registerRequestHandler(TransportService transportService, Sea
401406 transportService ,
402407 FREE_CONTEXT_SCROLL_ACTION_NAME ,
403408 false ,
404- SearchFreeContextResponse ::readFrom
409+ SearchFreeContextResponse ::readFrom ,
410+ namedWriteableRegistry
405411 );
406412
407413 // TODO: remove this handler once the lowest compatible version stops using it
@@ -411,7 +417,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
411417 OriginalIndices .readOriginalIndices (in );
412418 return res ;
413419 }, freeContextHandler );
414- TransportActionProxy .registerProxyAction (transportService , FREE_CONTEXT_ACTION_NAME , false , SearchFreeContextResponse ::readFrom );
420+ TransportActionProxy .registerProxyAction (
421+ transportService ,
422+ FREE_CONTEXT_ACTION_NAME ,
423+ false ,
424+ SearchFreeContextResponse ::readFrom ,
425+ namedWriteableRegistry
426+ );
415427
416428 transportService .registerRequestHandler (
417429 CLEAR_SCROLL_CONTEXTS_ACTION_NAME ,
@@ -426,7 +438,8 @@ public static void registerRequestHandler(TransportService transportService, Sea
426438 transportService ,
427439 CLEAR_SCROLL_CONTEXTS_ACTION_NAME ,
428440 false ,
429- (in ) -> ActionResponse .Empty .INSTANCE
441+ (in ) -> ActionResponse .Empty .INSTANCE ,
442+ namedWriteableRegistry
430443 );
431444
432445 transportService .registerRequestHandler (
@@ -435,7 +448,7 @@ public static void registerRequestHandler(TransportService transportService, Sea
435448 ShardSearchRequest ::new ,
436449 (request , channel , task ) -> searchService .executeDfsPhase (request , (SearchShardTask ) task , new ChannelActionListener <>(channel ))
437450 );
438- TransportActionProxy .registerProxyAction (transportService , DFS_ACTION_NAME , true , DfsSearchResult ::new );
451+ TransportActionProxy .registerProxyAction (transportService , DFS_ACTION_NAME , true , DfsSearchResult ::new , namedWriteableRegistry );
439452
440453 transportService .registerRequestHandler (
441454 QUERY_ACTION_NAME ,
@@ -451,7 +464,8 @@ public static void registerRequestHandler(TransportService transportService, Sea
451464 transportService ,
452465 QUERY_ACTION_NAME ,
453466 true ,
454- (request ) -> ((ShardSearchRequest ) request ).numberOfShards () == 1 ? QueryFetchSearchResult ::new : QuerySearchResult ::new
467+ (request ) -> ((ShardSearchRequest ) request ).numberOfShards () == 1 ? QueryFetchSearchResult ::new : QuerySearchResult ::new ,
468+ namedWriteableRegistry
455469 );
456470
457471 transportService .registerRequestHandler (
@@ -465,7 +479,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
465479 channel .getVersion ()
466480 )
467481 );
468- TransportActionProxy .registerProxyAction (transportService , QUERY_ID_ACTION_NAME , true , QuerySearchResult ::new );
482+ TransportActionProxy .registerProxyAction (
483+ transportService ,
484+ QUERY_ID_ACTION_NAME ,
485+ true ,
486+ QuerySearchResult ::new ,
487+ namedWriteableRegistry
488+ );
469489
470490 transportService .registerRequestHandler (
471491 QUERY_SCROLL_ACTION_NAME ,
@@ -478,7 +498,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
478498 channel .getVersion ()
479499 )
480500 );
481- TransportActionProxy .registerProxyAction (transportService , QUERY_SCROLL_ACTION_NAME , true , ScrollQuerySearchResult ::new );
501+ TransportActionProxy .registerProxyAction (
502+ transportService ,
503+ QUERY_SCROLL_ACTION_NAME ,
504+ true ,
505+ ScrollQuerySearchResult ::new ,
506+ namedWriteableRegistry
507+ );
482508
483509 transportService .registerRequestHandler (
484510 QUERY_FETCH_SCROLL_ACTION_NAME ,
@@ -490,7 +516,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
490516 new ChannelActionListener <>(channel )
491517 )
492518 );
493- TransportActionProxy .registerProxyAction (transportService , QUERY_FETCH_SCROLL_ACTION_NAME , true , ScrollQueryFetchSearchResult ::new );
519+ TransportActionProxy .registerProxyAction (
520+ transportService ,
521+ QUERY_FETCH_SCROLL_ACTION_NAME ,
522+ true ,
523+ ScrollQueryFetchSearchResult ::new ,
524+ namedWriteableRegistry
525+ );
494526
495527 final TransportRequestHandler <RankFeatureShardRequest > rankShardFeatureRequest = (request , channel , task ) -> searchService
496528 .executeRankFeaturePhase (request , (SearchShardTask ) task , new ChannelActionListener <>(channel ));
@@ -500,7 +532,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
500532 RankFeatureShardRequest ::new ,
501533 rankShardFeatureRequest
502534 );
503- TransportActionProxy .registerProxyAction (transportService , RANK_FEATURE_SHARD_ACTION_NAME , true , RankFeatureResult ::new );
535+ TransportActionProxy .registerProxyAction (
536+ transportService ,
537+ RANK_FEATURE_SHARD_ACTION_NAME ,
538+ true ,
539+ RankFeatureResult ::new ,
540+ namedWriteableRegistry
541+ );
504542
505543 final TransportRequestHandler <ShardFetchRequest > shardFetchRequestHandler = (request , channel , task ) -> searchService
506544 .executeFetchPhase (request , (SearchShardTask ) task , new ChannelActionListener <>(channel ));
@@ -510,7 +548,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
510548 ShardFetchRequest ::new ,
511549 shardFetchRequestHandler
512550 );
513- TransportActionProxy .registerProxyAction (transportService , FETCH_ID_SCROLL_ACTION_NAME , true , FetchSearchResult ::new );
551+ TransportActionProxy .registerProxyAction (
552+ transportService ,
553+ FETCH_ID_SCROLL_ACTION_NAME ,
554+ true ,
555+ FetchSearchResult ::new ,
556+ namedWriteableRegistry
557+ );
514558
515559 transportService .registerRequestHandler (
516560 FETCH_ID_ACTION_NAME ,
@@ -520,15 +564,27 @@ public static void registerRequestHandler(TransportService transportService, Sea
520564 ShardFetchSearchRequest ::new ,
521565 shardFetchRequestHandler
522566 );
523- TransportActionProxy .registerProxyAction (transportService , FETCH_ID_ACTION_NAME , true , FetchSearchResult ::new );
567+ TransportActionProxy .registerProxyAction (
568+ transportService ,
569+ FETCH_ID_ACTION_NAME ,
570+ true ,
571+ FetchSearchResult ::new ,
572+ namedWriteableRegistry
573+ );
524574
525575 transportService .registerRequestHandler (
526576 QUERY_CAN_MATCH_NODE_NAME ,
527577 transportService .getThreadPool ().executor (ThreadPool .Names .SEARCH_COORDINATION ),
528578 CanMatchNodeRequest ::new ,
529579 (request , channel , task ) -> searchService .canMatch (request , new ChannelActionListener <>(channel ))
530580 );
531- TransportActionProxy .registerProxyAction (transportService , QUERY_CAN_MATCH_NODE_NAME , true , CanMatchNodeResponse ::new );
581+ TransportActionProxy .registerProxyAction (
582+ transportService ,
583+ QUERY_CAN_MATCH_NODE_NAME ,
584+ true ,
585+ CanMatchNodeResponse ::new ,
586+ namedWriteableRegistry
587+ );
532588 }
533589
534590 private static Executor buildFreeContextExecutor (TransportService transportService ) {
0 commit comments