From 51111a81063977c2ac89df79be4aff83bc3bf92f Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Mon, 26 Mar 2018 13:56:47 -0400 Subject: [PATCH] CCR: Stop FollowExistingIndexAction after report failure (#4111) We check for the existence of both leader and follower index, then properly report to the caller. However, we do not return after reporting failure. This causes the caller receive exception twice: IllegalArgumentException then NullPointerException. This commit makes sure to stop the action after reporting failure. --- .../ccr/action/FollowExistingIndexAction.java | 2 ++ .../xpack/ccr/ShardChangesIT.java | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowExistingIndexAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowExistingIndexAction.java index 0ea6de6fe7b..c200acf9ad7 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowExistingIndexAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/FollowExistingIndexAction.java @@ -156,12 +156,14 @@ public class FollowExistingIndexAction extends Action client().execute(FollowExistingIndexAction.INSTANCE, followRequest).actionGet()); + // Follower index does not exist. + followRequest.setLeaderIndex("test-leader"); + followRequest.setFollowIndex("non-existent-follower"); + expectThrows(IllegalArgumentException.class, () -> client().execute(FollowExistingIndexAction.INSTANCE, followRequest).actionGet()); + // Both indices do not exist. + followRequest.setLeaderIndex("non-existent-leader"); + followRequest.setFollowIndex("non-existent-follower"); + expectThrows(IllegalArgumentException.class, () -> client().execute(FollowExistingIndexAction.INSTANCE, followRequest).actionGet()); + } + private CheckedRunnable assertTask(final int numberOfPrimaryShards, final Map numDocsPerShard) { return () -> { final ClusterState clusterState = client().admin().cluster().prepareState().get().getState();