From d9eb4c049fd881c25d7b8047061e72c933dce032 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Mon, 22 Jan 2018 15:51:55 +0100 Subject: [PATCH] Trim down usages of `ShardOperationFailedException` interface (elastic/x-pack-elasticsearch#3662) In many cases we use the `ShardOperationFailedException` interface to abstract an exception that can only be of one type, namely `DefaultShardOperationException`. There is no need to use the interface in such cases, the concrete type should be used instead. That has the additional advantage of simplifying parsing such exceptions back from rest responses for the high-level REST client. Original commit: elastic/x-pack-elasticsearch@b2259afcbfadedc6765eb672d7ad3848d16e0242 --- .../admin/indices/stats/IndicesStatsResponseTestUtils.java | 6 +++--- .../xpack/graph/action/TransportGraphExploreAction.java | 4 ---- .../collector/indices/IndexRecoveryMonitoringDocTests.java | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java b/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java index fb036e75c2d..18f4028b6bb 100644 --- a/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java +++ b/plugin/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsResponseTestUtils.java @@ -5,7 +5,7 @@ */ package org.elasticsearch.action.admin.indices.stats; -import org.elasticsearch.action.ShardOperationFailedException; +import org.elasticsearch.action.support.DefaultShardOperationFailedException; import java.util.List; @@ -14,8 +14,8 @@ public class IndicesStatsResponseTestUtils { /** * Gives access to package private IndicesStatsResponse constructor for test purpose. **/ - public static IndicesStatsResponse newIndicesStatsResponse(ShardStats[] shards, int totalShards, int successfulShards, - int failedShards, List shardFailures) { + public static IndicesStatsResponse newIndicesStatsResponse(ShardStats[] shards, int totalShards, int successfulShards, int failedShards, + List shardFailures) { return new IndicesStatsResponse(shards, totalShards, successfulShards, failedShards, shardFailures); } } diff --git a/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java index cba7bfa1bc4..c5db5ba0f45 100644 --- a/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java +++ b/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/action/TransportGraphExploreAction.java @@ -759,10 +759,6 @@ public class TransportGraphExploreAction extends HandledTransportAction shardFailures = new ArrayList<>(); + final List shardFailures = new ArrayList<>(); final Throwable reason = new NodeDisconnectedException(discoveryNodeZero, ""); shardFailures.add(new IndicesShardStoresResponse.Failure("_failed_node_id", "_failed_index", 1, reason));