@@ -421,36 +421,40 @@ abstract class ReplicationAction<Request extends ReplicationRequest<Request>,
421421 this .opType = opType ;
422422 }
423423
424- public void execute () throws Exception {
425- new ReplicationOperation <Request , ReplicaRequest , PrimaryResult >(request , new PrimaryRef (),
426- new ActionListener <PrimaryResult >() {
424+ public void execute () {
425+ try {
426+ new ReplicationOperation <Request , ReplicaRequest , PrimaryResult >(request , new PrimaryRef (),
427+ new ActionListener <PrimaryResult >() {
428+ @ Override
429+ public void onResponse (PrimaryResult result ) {
430+ result .respond (listener );
431+ }
432+
433+ @ Override
434+ public void onFailure (Exception e ) {
435+ listener .onFailure (e );
436+ }
437+ }, new ReplicasRef (), () -> null , logger , opType ) {
438+
427439 @ Override
428- public void onResponse ( PrimaryResult result ) {
429- result . respond ( listener );
440+ protected List < ShardRouting > getShards ( ShardId shardId , ClusterState state ) {
441+ return replicationGroup . shardRoutings ( );
430442 }
431443
432444 @ Override
433- public void onFailure ( Exception e ) {
434- listener . onFailure ( e ) ;
445+ protected String checkActiveShardCount ( ) {
446+ return null ;
435447 }
436- }, new ReplicasRef (), () -> null , logger , opType ) {
437448
438- @ Override
439- protected List <ShardRouting > getShards (ShardId shardId , ClusterState state ) {
440- return replicationGroup .shardRoutings ();
441- }
442-
443- @ Override
444- protected String checkActiveShardCount () {
445- return null ;
446- }
447-
448- @ Override
449- protected Set <String > getInSyncAllocationIds (ShardId shardId , ClusterState clusterState ) {
450- return replicationGroup .shardRoutings ().stream ().filter (ShardRouting ::active ).map (r -> r .allocationId ().getId ())
451- .collect (Collectors .toSet ());
452- }
453- }.execute ();
449+ @ Override
450+ protected Set <String > getInSyncAllocationIds (ShardId shardId , ClusterState clusterState ) {
451+ return replicationGroup .shardRoutings ().stream ().filter (ShardRouting ::active ).map (r -> r .allocationId ().getId ())
452+ .collect (Collectors .toSet ());
453+ }
454+ }.execute ();
455+ } catch (Exception e ) {
456+ listener .onFailure (e );
457+ }
454458 }
455459
456460 protected abstract PrimaryResult performOnPrimary (IndexShard primary , Request request ) throws Exception ;
0 commit comments