|
20 | 20 | package org.elasticsearch.index.reindex; |
21 | 21 |
|
22 | 22 | import org.elasticsearch.ElasticsearchException; |
| 23 | +import org.elasticsearch.ExceptionsHelper; |
23 | 24 | import org.elasticsearch.action.ActionFuture; |
24 | 25 | import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; |
25 | 26 | import org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup; |
|
37 | 38 | import static org.hamcrest.Matchers.allOf; |
38 | 39 | import static org.hamcrest.Matchers.both; |
39 | 40 | import static org.hamcrest.Matchers.empty; |
| 41 | +import static org.hamcrest.Matchers.equalTo; |
40 | 42 | import static org.hamcrest.Matchers.greaterThan; |
41 | 43 | import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
42 | 44 | import static org.hamcrest.Matchers.hasSize; |
@@ -191,13 +193,15 @@ private ListTasksResponse rethrottleTask(TaskId taskToRethrottle, float newReque |
191 | 193 | assertThat(rethrottleResponse.getTasks(), hasSize(1)); |
192 | 194 | response.set(rethrottleResponse); |
193 | 195 | } catch (ElasticsearchException e) { |
194 | | - if (e.getCause() instanceof IllegalArgumentException) { |
195 | | - // We want to retry in this case so we throw an assertion error |
196 | | - logger.info("caught unprepared task, retrying until prepared"); |
197 | | - throw new AssertionError("Rethrottle request for task [" + taskToRethrottle.getId() + "] failed", e); |
198 | | - } else { |
| 196 | + Throwable unwrapped = ExceptionsHelper.unwrap(e, IllegalArgumentException.class); |
| 197 | + if (unwrapped == null) { |
199 | 198 | throw e; |
200 | 199 | } |
| 200 | + // We want to retry in this case so we throw an assertion error |
| 201 | + assertThat(unwrapped.getMessage(), equalTo("task [" + taskToRethrottle.getId() |
| 202 | + + "] has not yet been initialized to the point where it knows how to rethrottle itself")); |
| 203 | + logger.info("caught unprepared task, retrying until prepared"); |
| 204 | + throw new AssertionError("Rethrottle request for task [" + taskToRethrottle.getId() + "] failed", e); |
201 | 205 | } |
202 | 206 | }); |
203 | 207 |
|
|
0 commit comments