summaryrefslogtreecommitdiff
path: root/core/src/test/java/org
diff options
context:
space:
mode:
authorJason Tedor <jason@tedor.me>2016-07-04 08:41:06 -0400
committerGitHub <noreply@github.com>2016-07-04 08:41:06 -0400
commit3343ceeae44f3d28e3c1ba7861886848df74e390 (patch)
tree7223f17293ef950db42bb2843d049528befcee38 /core/src/test/java/org
parent86d2e883620ef44afb5fed7ed86854061d49f966 (diff)
Do not catch throwable
Today throughout the codebase, catch throwable is used with reckless abandon. This is dangerous because the throwable could be a fatal virtual machine error resulting from an internal error in the JVM, or an out of memory error or a stack overflow error that leaves the virtual machine in an unstable and unpredictable state. This commit removes catch throwable from the codebase and removes the temptation to use it by modifying listener APIs to receive instances of Exception instead of the top-level Throwable. Relates #19231
Diffstat (limited to 'core/src/test/java/org')
-rw-r--r--core/src/test/java/org/elasticsearch/ESExceptionTests.java48
-rw-r--r--core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java18
-rw-r--r--core/src/test/java/org/elasticsearch/action/ListenerActionIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/RejectionActionIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java5
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/main/MainActionTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java26
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java20
-rw-r--r--core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java21
-rw-r--r--core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java2
-rw-r--r--core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java18
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java32
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java56
-rw-r--r--core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java14
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java16
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractLifecycleRunnableTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractRunnableTests.java33
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/util/concurrent/ThreadContextTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandlerTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java10
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java30
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java9
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java3
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIntegrationIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java18
-rw-r--r--core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java10
-rw-r--r--core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java33
-rw-r--r--core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java14
-rw-r--r--core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushUtil.java4
-rw-r--r--core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java4
-rw-r--r--core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java11
-rw-r--r--core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java8
-rw-r--r--core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java12
-rw-r--r--core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java38
-rw-r--r--core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java40
-rw-r--r--core/src/test/java/org/elasticsearch/monitor/jvm/JvmMonitorTests.java12
-rw-r--r--core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java31
-rw-r--r--core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java3
-rw-r--r--core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java6
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java4
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java2
-rw-r--r--core/src/test/java/org/elasticsearch/test/geo/RandomShapeGenerator.java21
-rw-r--r--core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java15
-rw-r--r--core/src/test/java/org/elasticsearch/update/UpdateIT.java13
-rw-r--r--core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java2
87 files changed, 441 insertions, 458 deletions
diff --git a/core/src/test/java/org/elasticsearch/ESExceptionTests.java b/core/src/test/java/org/elasticsearch/ESExceptionTests.java
index d27790beed..5e761a97c6 100644
--- a/core/src/test/java/org/elasticsearch/ESExceptionTests.java
+++ b/core/src/test/java/org/elasticsearch/ESExceptionTests.java
@@ -57,6 +57,14 @@ import static org.hamcrest.Matchers.equalTo;
public class ESExceptionTests extends ESTestCase {
private static final ToXContent.Params PARAMS = ToXContent.EMPTY_PARAMS;
+ private class UnknownException extends Exception {
+
+ UnknownException(final String message, final Exception cause) {
+ super(message, cause);
+ }
+
+ }
+
public void testStatus() {
ElasticsearchException exception = new ElasticsearchException("test");
assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
@@ -296,7 +304,7 @@ public class ESExceptionTests extends ESTestCase {
out.writeThrowable(ex);
StreamInput in = out.bytes().streamInput();
- ParsingException e = in.readThrowable();
+ ParsingException e = in.readException();
assertEquals(ex.getIndex(), e.getIndex());
assertEquals(ex.getMessage(), e.getMessage());
assertEquals(ex.getLineNumber(), e.getLineNumber());
@@ -305,23 +313,27 @@ public class ESExceptionTests extends ESTestCase {
public void testSerializeUnknownException() throws IOException {
BytesStreamOutput out = new BytesStreamOutput();
- ParsingException ParsingException = new ParsingException(1, 2, "foobar", null);
- Throwable ex = new Throwable("eggplant", ParsingException);
+ ParsingException parsingException = new ParsingException(1, 2, "foobar", null);
+ final Exception ex = new UnknownException("eggplant", parsingException);
out.writeThrowable(ex);
StreamInput in = out.bytes().streamInput();
- Throwable throwable = in.readThrowable();
- assertEquals("throwable: eggplant", throwable.getMessage());
+ Throwable throwable = in.readException();
+ assertEquals("unknown_exception: eggplant", throwable.getMessage());
assertTrue(throwable instanceof ElasticsearchException);
ParsingException e = (ParsingException)throwable.getCause();
- assertEquals(ParsingException.getIndex(), e.getIndex());
- assertEquals(ParsingException.getMessage(), e.getMessage());
- assertEquals(ParsingException.getLineNumber(), e.getLineNumber());
- assertEquals(ParsingException.getColumnNumber(), e.getColumnNumber());
+ assertEquals(parsingException.getIndex(), e.getIndex());
+ assertEquals(parsingException.getMessage(), e.getMessage());
+ assertEquals(parsingException.getLineNumber(), e.getLineNumber());
+ assertEquals(parsingException.getColumnNumber(), e.getColumnNumber());
}
public void testWriteThrowable() throws IOException {
- Throwable[] causes = new Throwable[] {
+
+ final QueryShardException queryShardException = new QueryShardException(new Index("foo", "_na_"), "foobar", null);
+ final UnknownException unknownException = new UnknownException("this exception is unknown", queryShardException);
+
+ final Exception[] causes = new Exception[]{
new IllegalStateException("foobar"),
new IllegalArgumentException("alalaal"),
new NullPointerException("boom"),
@@ -336,32 +348,30 @@ public class ESExceptionTests extends ESTestCase {
new StringIndexOutOfBoundsException("booom"),
new FileNotFoundException("booom"),
new NoSuchFileException("booom"),
- new AssertionError("booom", new NullPointerException()),
- new OutOfMemoryError("no memory left"),
new AlreadyClosedException("closed!!", new NullPointerException()),
new LockObtainFailedException("can't lock directory", new NullPointerException()),
- new Throwable("this exception is unknown", new QueryShardException(new Index("foo", "_na_"), "foobar", null) ), // somethin unknown
- };
- for (Throwable t : causes) {
+ unknownException};
+ for (final Exception cause : causes) {
BytesStreamOutput out = new BytesStreamOutput();
- ElasticsearchException ex = new ElasticsearchException("topLevel", t);
+ ElasticsearchException ex = new ElasticsearchException("topLevel", cause);
out.writeThrowable(ex);
StreamInput in = out.bytes().streamInput();
- ElasticsearchException e = in.readThrowable();
+ ElasticsearchException e = in.readException();
assertEquals(e.getMessage(), ex.getMessage());
assertTrue("Expected: " + e.getCause().getMessage() + " to contain: " +
ex.getCause().getClass().getName() + " but it didn't",
e.getCause().getMessage().contains(ex.getCause().getMessage()));
- if (ex.getCause().getClass() != Throwable.class) { // throwable is not directly mapped
+ if (ex.getCause().getClass() != UnknownException.class) { // unknown exception is not directly mapped
assertEquals(e.getCause().getClass(), ex.getCause().getClass());
} else {
assertEquals(e.getCause().getClass(), NotSerializableExceptionWrapper.class);
}
assertArrayEquals(e.getStackTrace(), ex.getStackTrace());
assertTrue(e.getStackTrace().length > 1);
- ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), t);
+ ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), cause);
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), ex);
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), e);
}
}
+
}
diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java
index 6a65b1d169..17ff204723 100644
--- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java
+++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java
@@ -219,12 +219,12 @@ public class ExceptionSerializationTests extends ESTestCase {
}
}
- private <T extends Throwable> T serialize(T exception) throws IOException {
+ private <T extends Exception> T serialize(T exception) throws IOException {
ElasticsearchAssertions.assertVersionSerializable(VersionUtils.randomVersion(random()), exception);
BytesStreamOutput out = new BytesStreamOutput();
out.writeThrowable(exception);
StreamInput in = out.bytes().streamInput();
- return in.readThrowable();
+ return in.readException();
}
public void testIllegalShardRoutingStateException() throws IOException {
@@ -546,12 +546,20 @@ public class ExceptionSerializationTests extends ESTestCase {
ex = serialize(new NotSerializableExceptionWrapper(new IllegalArgumentException("nono!")));
assertEquals("{\"type\":\"illegal_argument_exception\",\"reason\":\"illegal_argument_exception: nono!\"}", toXContent(ex));
- Throwable[] unknowns = new Throwable[]{
+ class UnknownException extends Exception {
+
+ public UnknownException(final String message) {
+ super(message);
+ }
+
+ }
+
+ Exception[] unknowns = new Exception[]{
new Exception("foobar"),
new ClassCastException("boom boom boom"),
- new UnsatisfiedLinkError("booom")
+ new UnknownException("boom")
};
- for (Throwable t : unknowns) {
+ for (Exception t : unknowns) {
if (randomBoolean()) {
t.addSuppressed(new UnsatisfiedLinkError("suppressed"));
t.addSuppressed(new NullPointerException());
diff --git a/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java b/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java
index 3976f665df..93389f898e 100644
--- a/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java
+++ b/core/src/test/java/org/elasticsearch/action/ListenerActionIT.java
@@ -51,7 +51,7 @@ public class ListenerActionIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
threadName.set(Thread.currentThread().getName());
failure.set(e);
latch.countDown();
diff --git a/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java b/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
index 6f10017025..6745906488 100644
--- a/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
+++ b/core/src/test/java/org/elasticsearch/action/RejectionActionIT.java
@@ -75,7 +75,7 @@ public class RejectionActionIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
responses.add(e);
latch.countDown();
}
@@ -92,7 +92,7 @@ public class RejectionActionIT extends ESIntegTestCase {
assertTrue("got unexpected reason..." + failure.reason(), failure.reason().toLowerCase(Locale.ENGLISH).contains("rejected"));
}
} else {
- Throwable t = (Throwable) response;
+ Exception t = (Exception) response;
Throwable unwrap = ExceptionsHelper.unwrapCause(t);
if (unwrap instanceof SearchPhaseExecutionException) {
SearchPhaseExecutionException e = (SearchPhaseExecutionException) unwrap;
diff --git a/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java b/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java
index 480c103df8..5d51253882 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java
@@ -100,7 +100,7 @@ public class HotThreadsIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
logger.error("FAILED", e);
hasErrors.set(true);
latch.countDown();
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java
index 594028f4e6..9027b3d372 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java
@@ -230,7 +230,7 @@ public class CancellableTasksTests extends TaskManagerTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
throwableReference.set(e);
responseLatch.countDown();
}
@@ -308,7 +308,7 @@ public class CancellableTasksTests extends TaskManagerTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
throwableReference.set(e);
responseLatch.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java
index 6f8e3fda15..f9045b5841 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java
@@ -738,12 +738,12 @@ public class TasksIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
throw new RuntimeException(e);
}
});
b.await();
-
+
// Now we can find it!
GetTaskResponse response = expectFinishedTask(new TaskId("fake:1"));
assertEquals("test", response.getTask().getTask().getAction());
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java
index 56756ad9fd..2c78786ab0 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java
@@ -338,7 +338,7 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
logger.warn("Couldn't get list of tasks", e);
responseLatch.countDown();
}
@@ -526,7 +526,7 @@ public class TransportTasksActionTests extends TaskManagerTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
responseLatch.countDown();
}
});
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteTests.java
index dac878eefe..657fec558b 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteTests.java
@@ -94,7 +94,7 @@ public class ClusterRerouteTests extends ESAllocationTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
}
};
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
index 3e7323dcee..428e859e34 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java
@@ -41,14 +41,11 @@ import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.index.query.TermsQueryBuilder;
-import org.elasticsearch.node.service.NodeService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
-import org.junit.Ignore;
import java.util.HashMap;
-import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
@@ -232,7 +229,7 @@ public class CreateIndexIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
throw new RuntimeException(e);
}
}
diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
index d62fe30f6f..58784fdb7d 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/MetaDataIndexTemplateServiceTests.java
@@ -19,7 +19,6 @@
package org.elasticsearch.action.admin.indices.template.put;
-import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.cluster.metadata.AliasValidator;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -172,8 +171,8 @@ public class MetaDataIndexTemplateServiceTests extends ESSingleNodeTestCase {
}
@Override
- public void onFailure(Throwable t) {
- throwables.add(t);
+ public void onFailure(Exception e) {
+ throwables.add(e);
}
});
return throwables;
@@ -205,8 +204,8 @@ public class MetaDataIndexTemplateServiceTests extends ESSingleNodeTestCase {
}
@Override
- public void onFailure(Throwable t) {
- throwables.add(t);
+ public void onFailure(Exception e) {
+ throwables.add(e);
latch.countDown();
}
});
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java b/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java
index 6d9987394f..4fa640b3ad 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java
@@ -149,7 +149,7 @@ public class RetryTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
this.lastFailure = e;
latch.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java b/core/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java
index 6111c4c995..7c39adc76f 100644
--- a/core/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java
+++ b/core/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java
@@ -201,7 +201,7 @@ public class TransportBulkActionTookTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
}
});
diff --git a/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java b/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java
index 3286c07e06..9ee5036131 100644
--- a/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java
+++ b/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java
@@ -111,7 +111,7 @@ public class BulkRequestModifierTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
}
});
@@ -157,7 +157,7 @@ public class BulkRequestModifierTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
}
public BulkResponse getResponse() {
diff --git a/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java b/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java
index 3e592d1c34..a8c550e01c 100644
--- a/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/main/MainActionTests.java
@@ -121,7 +121,7 @@ public class MainActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
logger.error("unexpected error", e);
}
});
diff --git a/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java b/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java
index 80492f0be6..8169a674be 100644
--- a/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java
@@ -45,15 +45,15 @@ public class ListenableActionFutureTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
error.set(e);
listenerCalled.countDown();
}
});
Thread networkThread = new Thread(new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- error.set(t);
+ public void onFailure(Exception e) {
+ error.set(e);
listenerCalled.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
index 00068c05ef..b78425cd2a 100644
--- a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
@@ -41,6 +41,8 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+import java.util.stream.IntStream;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
@@ -102,8 +104,8 @@ public class TransportActionFilterChainTests extends ESTestCase {
try {
assertThat(future.get(), notNullValue());
assertThat("shouldn't get here if an error is expected", errorExpected, equalTo(false));
- } catch(Throwable t) {
- assertThat("shouldn't get here if an error is not expected " + t.getMessage(), errorExpected, equalTo(true));
+ } catch (ExecutionException e) {
+ assertThat("shouldn't get here if an error is not expected " + e.getMessage(), errorExpected, equalTo(true));
}
List<RequestTestFilter> testFiltersByLastExecution = new ArrayList<>();
@@ -182,8 +184,8 @@ public class TransportActionFilterChainTests extends ESTestCase {
try {
assertThat(future.get(), notNullValue());
assertThat("shouldn't get here if an error is expected", errorExpected, equalTo(false));
- } catch(Throwable t) {
- assertThat("shouldn't get here if an error is not expected " + t.getMessage(), errorExpected, equalTo(true));
+ } catch(ExecutionException e) {
+ assertThat("shouldn't get here if an error is not expected " + e.getMessage(), errorExpected, equalTo(true));
}
List<ResponseTestFilter> testFiltersByLastExecution = new ArrayList<>();
@@ -252,7 +254,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
failures.add(e);
latch.countDown();
}
@@ -309,7 +311,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
failures.add(e);
latch.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java b/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java
index 1d65f277e3..5e49518bd5 100644
--- a/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java
@@ -491,7 +491,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase {
}
@Override
- public void sendResponse(Throwable error) throws IOException {
+ public void sendResponse(Exception exception) throws IOException {
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java b/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java
index 37cd74e00d..c6d17605eb 100644
--- a/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/master/TransportMasterNodeActionTests.java
@@ -167,7 +167,7 @@ public class TransportMasterNodeActionTests extends ESTestCase {
Request request = new Request();
PlainActionFuture<Response> listener = new PlainActionFuture<>();
- final Throwable exception = new Throwable();
+ final Exception exception = new Exception();
final Response response = new Response();
setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, allNodes));
@@ -342,7 +342,7 @@ public class TransportMasterNodeActionTests extends ESTestCase {
protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) throws Exception {
// The other node has become master, simulate failures of this node while publishing cluster state through ZenDiscovery
setState(clusterService, ClusterStateCreationUtils.state(localNode, remoteNode, allNodes));
- Throwable failure = randomBoolean()
+ Exception failure = randomBoolean()
? new Discovery.FailedToCommitClusterStateException("Fake error")
: new NotMasterException("Fake error");
listener.onFailure(failure);
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java
index 55e2a9d3cf..9f41f0e37c 100644
--- a/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/replication/ReplicationOperationTests.java
@@ -81,11 +81,11 @@ public class ReplicationOperationTests extends ESTestCase {
final Set<ShardRouting> expectedReplicas = getExpectedReplicas(shardId, state);
- final Map<ShardRouting, Throwable> expectedFailures = new HashMap<>();
+ final Map<ShardRouting, Exception> expectedFailures = new HashMap<>();
final Set<ShardRouting> expectedFailedShards = new HashSet<>();
for (ShardRouting replica : expectedReplicas) {
if (randomBoolean()) {
- Throwable t;
+ Exception t;
boolean criticalFailure = randomBoolean();
if (criticalFailure) {
t = new CorruptIndexException("simulated", (String) null);
@@ -166,7 +166,7 @@ public class ReplicationOperationTests extends ESTestCase {
final Set<ShardRouting> expectedReplicas = getExpectedReplicas(shardId, state);
- final Map<ShardRouting, Throwable> expectedFailures = new HashMap<>();
+ final Map<ShardRouting, Exception> expectedFailures = new HashMap<>();
final ShardRouting failedReplica = randomFrom(new ArrayList<>(expectedReplicas));
expectedFailures.put(failedReplica, new CorruptIndexException("simulated", (String) null));
@@ -175,9 +175,9 @@ public class ReplicationOperationTests extends ESTestCase {
final ClusterState finalState = state;
final TestReplicaProxy replicasProxy = new TestReplicaProxy(expectedFailures) {
@Override
- public void failShard(ShardRouting replica, ShardRouting primary, String message, Throwable throwable,
- Runnable onSuccess, Consumer<Throwable> onPrimaryDemoted,
- Consumer<Throwable> onIgnoredFailure) {
+ public void failShard(ShardRouting replica, ShardRouting primary, String message, Exception exception,
+ Runnable onSuccess, Consumer<Exception> onPrimaryDemoted,
+ Consumer<Exception> onIgnoredFailure) {
assertThat(replica, equalTo(failedReplica));
onPrimaryDemoted.accept(new ElasticsearchException("the king is dead"));
}
@@ -185,7 +185,7 @@ public class ReplicationOperationTests extends ESTestCase {
AtomicBoolean primaryFailed = new AtomicBoolean();
final TestPrimary primary = new TestPrimary(primaryShard, primaryTerm) {
@Override
- public void failShard(String message, Throwable throwable) {
+ public void failShard(String message, Exception exception) {
assertTrue(primaryFailed.compareAndSet(false, true));
}
};
@@ -376,8 +376,8 @@ public class ReplicationOperationTests extends ESTestCase {
}
@Override
- public void failShard(String message, Throwable throwable) {
- throw new AssertionError("should shouldn't be failed with [" + message + "]", throwable);
+ public void failShard(String message, Exception exception) {
+ throw new AssertionError("should shouldn't be failed with [" + message + "]", exception);
}
@Override
@@ -415,7 +415,7 @@ public class ReplicationOperationTests extends ESTestCase {
static class TestReplicaProxy implements ReplicationOperation.Replicas<Request> {
- final Map<ShardRouting, Throwable> opFailures;
+ final Map<ShardRouting, Exception> opFailures;
final Set<ShardRouting> failedReplicas = ConcurrentCollections.newConcurrentSet();
@@ -423,7 +423,7 @@ public class ReplicationOperationTests extends ESTestCase {
this(Collections.emptyMap());
}
- TestReplicaProxy(Map<ShardRouting, Throwable> opFailures) {
+ TestReplicaProxy(Map<ShardRouting, Exception> opFailures) {
this.opFailures = opFailures;
}
@@ -438,8 +438,8 @@ public class ReplicationOperationTests extends ESTestCase {
}
@Override
- public void failShard(ShardRouting replica, ShardRouting primary, String message, Throwable throwable, Runnable onSuccess,
- Consumer<Throwable> onPrimaryDemoted, Consumer<Throwable> onIgnoredFailure) {
+ public void failShard(ShardRouting replica, ShardRouting primary, String message, Exception exception, Runnable onSuccess,
+ Consumer<Exception> onPrimaryDemoted, Consumer<Exception> onIgnoredFailure) {
if (failedReplicas.add(replica) == false) {
fail("replica [" + replica + "] was failed twice");
}
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
index faa6a031f3..de2ddabb0f 100644
--- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
@@ -785,7 +785,7 @@ public class TransportReplicationActionTests extends ESTestCase {
}
@Override
- public void failShard(String reason, @Nullable Throwable e) {
+ public void failShard(String reason, @Nullable Exception e) {
throw new UnsupportedOperationException();
}
@@ -856,9 +856,9 @@ public class TransportReplicationActionTests extends ESTestCase {
}
@Override
- public void sendResponse(Throwable error) throws IOException {
- consumer.accept(error);
- listener.onFailure(error);
+ public void sendResponse(Exception exception) throws IOException {
+ consumer.accept(exception);
+ listener.onFailure(exception);
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java
index 7b31295963..80e689743f 100644
--- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportWriteActionTests.java
@@ -179,7 +179,7 @@ public class TransportWriteActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
throw new RuntimeException(e);
}
}
diff --git a/core/src/test/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java b/core/src/test/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java
index c26d376b58..37abc4d5ee 100644
--- a/core/src/test/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/single/instance/TransportInstanceSingleOperationActionTests.java
@@ -179,9 +179,9 @@ public class TransportInstanceSingleOperationActionTests extends ESTestCase {
action.new AsyncSingleAction(request, listener).start();
listener.get();
fail("expected ClusterBlockException");
- } catch (Throwable t) {
- if (ExceptionsHelper.unwrap(t, ClusterBlockException.class) == null) {
- logger.info("expected ClusterBlockException but got ", t);
+ } catch (Exception e) {
+ if (ExceptionsHelper.unwrap(e, ClusterBlockException.class) == null) {
+ logger.info("expected ClusterBlockException but got ", e);
fail("expected ClusterBlockException");
}
}
@@ -317,9 +317,9 @@ public class TransportInstanceSingleOperationActionTests extends ESTestCase {
assertThat(transport.capturedRequests().length, equalTo(0));
try {
listener.get();
- } catch (Throwable t) {
- if (ExceptionsHelper.unwrap(t, IllegalStateException.class) == null) {
- logger.info("expected IllegalStateException but got ", t);
+ } catch (Exception e) {
+ if (ExceptionsHelper.unwrap(e, IllegalStateException.class) == null) {
+ logger.info("expected IllegalStateException but got ", e);
fail("expected and IllegalStateException");
}
}
diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java
index 6ba31fdb88..d8fd7916b5 100644
--- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java
@@ -389,19 +389,15 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
TestConfig[] testConfigs = generateTestConfigs(20, testDocs, testFieldSettings);
for (TestConfig test : testConfigs) {
- try {
- TermVectorsRequestBuilder request = getRequestForConfig(test);
- if (test.expectedException != null) {
- assertThrows(request, test.expectedException);
- continue;
- }
-
- TermVectorsResponse response = request.get();
- Fields luceneTermVectors = getTermVectorsFromLucene(directoryReader, test.doc);
- validateResponse(response, luceneTermVectors, test);
- } catch (Throwable t) {
- throw new Exception("Test exception while running " + test.toString(), t);
+ TermVectorsRequestBuilder request = getRequestForConfig(test);
+ if (test.expectedException != null) {
+ assertThrows(request, test.expectedException);
+ continue;
}
+
+ TermVectorsResponse response = request.get();
+ Fields luceneTermVectors = getTermVectorsFromLucene(directoryReader, test.doc);
+ validateResponse(response, luceneTermVectors, test);
}
}
diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java
index 57a89c82cc..5ed4f3252d 100644
--- a/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java
+++ b/core/src/test/java/org/elasticsearch/action/termvectors/MultiTermVectorsIT.java
@@ -56,21 +56,16 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
for (int i = 0; i < testConfigs.length; i++) {
TestConfig test = testConfigs[i];
- try {
- MultiTermVectorsItemResponse item = responseItems[i];
- if (test.expectedException != null) {
- assertTrue(item.isFailed());
- continue;
- } else if (item.isFailed()) {
- fail(item.getFailure().getCause().getMessage());
- }
- Fields luceneTermVectors = getTermVectorsFromLucene(directoryReader, test.doc);
- validateResponse(item.getResponse(), luceneTermVectors, test);
- } catch (Throwable t) {
- throw new Exception("Test exception while running " + test.toString(), t);
+ MultiTermVectorsItemResponse item = responseItems[i];
+ if (test.expectedException != null) {
+ assertTrue(item.isFailed());
+ continue;
+ } else if (item.isFailed()) {
+ fail(item.getFailure().getCause().getMessage());
}
+ Fields luceneTermVectors = getTermVectorsFromLucene(directoryReader, test.doc);
+ validateResponse(item.getResponse(), luceneTermVectors, test);
}
-
}
public void testMissingIndexThrowsMissingIndex() throws Exception {
diff --git a/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java b/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java
index 196b053ff8..276a43581a 100644
--- a/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java
+++ b/core/src/test/java/org/elasticsearch/client/AbstractClientHeadersTestCase.java
@@ -179,7 +179,7 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception t) {
Throwable e = unwrap(t, InternalException.class);
assertThat("expected action [" + action + "] to throw an internal exception", e, notNullValue());
assertThat(action, equalTo(((InternalException) e).action));
diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java
index 5c07f5e6f2..42ec724ed5 100644
--- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java
@@ -19,7 +19,6 @@
package org.elasticsearch.client.transport;
-import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.cluster.node.liveness.LivenessResponse;
import org.elasticsearch.action.admin.cluster.node.liveness.TransportLivenessAction;
@@ -171,7 +170,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
finalFailures.incrementAndGet();
finalFailure.set(e);
latch.countDown();
diff --git a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
index 61bb898acc..aad2aa212a 100644
--- a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
@@ -395,8 +395,8 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- failure.set(t);
+ public void onFailure(String source, Exception e) {
+ failure.set(e);
latch.countDown();
}
});
diff --git a/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java b/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java
index 7f0ac1a6e4..d387d6f7d4 100644
--- a/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/action/shard/ShardStateActionTests.java
@@ -148,7 +148,7 @@ public class ShardStateActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
success.set(false);
latch.countDown();
assert false;
@@ -196,7 +196,7 @@ public class ShardStateActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
success.set(false);
latch.countDown();
assert false;
@@ -245,9 +245,9 @@ public class ShardStateActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
success.set(false);
- throwable.set(t);
+ throwable.set(e);
latch.countDown();
assert false;
}
@@ -281,7 +281,7 @@ public class ShardStateActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
failure.set(true);
}
});
@@ -313,7 +313,7 @@ public class ShardStateActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
success.set(false);
latch.countDown();
assert false;
@@ -348,8 +348,8 @@ public class ShardStateActionTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
- failure.set(t);
+ public void onFailure(Exception e) {
+ failure.set(e);
latch.countDown();
}
});
@@ -401,7 +401,7 @@ public class ShardStateActionTests extends ESTestCase {
}
}
- private Throwable getSimulatedFailure() {
+ private Exception getSimulatedFailure() {
return new CorruptIndexException("simulated", (String) null);
}
}
diff --git a/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java b/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java
index 0918358a51..8718c47921 100644
--- a/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/health/ClusterStateHealthTests.java
@@ -118,8 +118,8 @@ public class ClusterStateHealthTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- logger.warn("unexpected failure", t);
+ public void onFailure(String source, Exception e) {
+ logger.warn("unexpected failure", e);
}
});
diff --git a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java
index 7907ad3e63..23713832ed 100644
--- a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceIT.java
@@ -94,7 +94,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onAllNodesAcked(@Nullable Throwable t) {
+ public void onAllNodesAcked(@Nullable Exception e) {
allNodesAcked.set(true);
latch.countDown();
}
@@ -127,8 +127,8 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- logger.error("failed to execute callback in test {}", t, source);
+ public void onFailure(String source, Exception e) {
+ logger.error("failed to execute callback in test {}", e, source);
onFailure.set(true);
latch.countDown();
}
@@ -165,7 +165,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onAllNodesAcked(@Nullable Throwable t) {
+ public void onAllNodesAcked(@Nullable Exception e) {
allNodesAcked.set(true);
latch.countDown();
}
@@ -198,8 +198,8 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- logger.error("failed to execute callback in test {}", t, source);
+ public void onFailure(String source, Exception e) {
+ logger.error("failed to execute callback in test {}", e, source);
onFailure.set(true);
latch.countDown();
}
@@ -240,7 +240,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onAllNodesAcked(@Nullable Throwable t) {
+ public void onAllNodesAcked(@Nullable Exception e) {
allNodesAcked.set(true);
latch.countDown();
}
@@ -272,8 +272,8 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- logger.error("failed to execute callback in test {}", t, source);
+ public void onFailure(String source, Exception e) {
+ logger.error("failed to execute callback in test {}", e, source);
onFailure.set(true);
latch.countDown();
}
@@ -313,7 +313,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onAllNodesAcked(@Nullable Throwable t) {
+ public void onAllNodesAcked(@Nullable Exception e) {
allNodesAcked.set(true);
latch.countDown();
}
@@ -346,8 +346,8 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- logger.error("failed to execute callback in test {}", t, source);
+ public void onFailure(String source, Exception e) {
+ logger.error("failed to execute callback in test {}", e, source);
onFailure.set(true);
latch.countDown();
}
@@ -388,7 +388,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
invoked1.countDown();
fail();
}
@@ -403,7 +403,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
@@ -458,7 +458,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
invoked3.countDown();
fail();
}
@@ -473,7 +473,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
diff --git a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java
index 66f96f8cd3..c94e441aea 100644
--- a/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/cluster/service/ClusterServiceTests.java
@@ -149,8 +149,8 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- throw new RuntimeException(t);
+ public void onFailure(String source, Exception e) {
+ throw new RuntimeException(e);
}
});
@@ -163,7 +163,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
timedOut.countDown();
}
@@ -183,8 +183,8 @@ public class ClusterServiceTests extends ESTestCase {
final CountDownLatch allProcessed = new CountDownLatch(1);
clusterService.submitStateUpdateTask("test3", new ClusterStateUpdateTask() {
@Override
- public void onFailure(String source, Throwable t) {
- throw new RuntimeException(t);
+ public void onFailure(String source, Exception e) {
+ throw new RuntimeException(e);
}
@Override
@@ -212,7 +212,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
taskFailed[0] = true;
latch1.countDown();
}
@@ -237,7 +237,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
taskFailed[0] = true;
latch2.countDown();
}
@@ -286,7 +286,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
}
}
);
@@ -326,9 +326,9 @@ public class ClusterServiceTests extends ESTestCase {
ClusterStateTaskListener listener = new ClusterStateTaskListener() {
@Override
- public void onFailure(String source, Throwable t) {
- logger.error("unexpected failure: [{}]", t, source);
- failures.add(new Tuple<>(source, t));
+ public void onFailure(String source, Exception e) {
+ logger.error("unexpected failure: [{}]", e, source);
+ failures.add(new Tuple<>(source, e));
updateLatch.countDown();
}
@@ -387,8 +387,8 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- fail(ExceptionsHelper.detailedMessage(t));
+ public void onFailure(String source, Exception e) {
+ fail(ExceptionsHelper.detailedMessage(e));
}
})) ;
}
@@ -523,8 +523,8 @@ public class ClusterServiceTests extends ESTestCase {
final CountDownLatch updateLatch = new CountDownLatch(totalTaskCount);
final ClusterStateTaskListener listener = new ClusterStateTaskListener() {
@Override
- public void onFailure(String source, Throwable t) {
- fail(ExceptionsHelper.detailedMessage(t));
+ public void onFailure(String source, Exception e) {
+ fail(ExceptionsHelper.detailedMessage(e));
}
@Override
@@ -647,8 +647,8 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- fail(ExceptionsHelper.detailedMessage(t));
+ public void onFailure(String source, Exception e) {
+ fail(ExceptionsHelper.detailedMessage(e));
}
};
@@ -693,7 +693,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
@@ -710,7 +710,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
latch.countDown();
}
});
@@ -727,7 +727,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
@@ -745,7 +745,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
@@ -788,7 +788,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
@@ -807,7 +807,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
latch.countDown();
}
});
@@ -824,7 +824,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
@@ -841,7 +841,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
@@ -859,7 +859,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
});
@@ -902,7 +902,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
}
public void close() {
@@ -930,7 +930,7 @@ public class ClusterServiceTests extends ESTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
latch.countDown();
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java b/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java
index bb9d23db1c..f10a0da302 100644
--- a/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java
+++ b/core/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java
@@ -43,7 +43,7 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
final int BYTES_PER_THREAD = scaledRandomIntBetween(500, 4500);
final Thread[] threads = new Thread[NUM_THREADS];
final AtomicBoolean tripped = new AtomicBoolean(false);
- final AtomicReference<Throwable> lastException = new AtomicReference<>(null);
+ final AtomicReference<Exception> lastException = new AtomicReference<>(null);
final MemoryCircuitBreaker breaker = new MemoryCircuitBreaker(new ByteSizeValue((BYTES_PER_THREAD * NUM_THREADS) - 1), 1.0, logger);
@@ -60,8 +60,8 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
} else {
assertThat(tripped.compareAndSet(false, true), equalTo(true));
}
- } catch (Throwable e2) {
- lastException.set(e2);
+ } catch (Exception e) {
+ lastException.set(e);
}
}
}
@@ -117,8 +117,8 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
} else {
assertThat(tripped.compareAndSet(false, true), equalTo(true));
}
- } catch (Throwable e2) {
- lastException.set(e2);
+ } catch (Exception e) {
+ lastException.set(e);
}
}
}
@@ -178,8 +178,8 @@ public class MemoryCircuitBreakerTests extends ESTestCase {
breaker.addEstimateBytesAndMaybeBreak(1L, "test");
} catch (CircuitBreakingException e) {
tripped.incrementAndGet();
- } catch (Throwable e2) {
- lastException.set(e2);
+ } catch (Exception e) {
+ lastException.set(e);
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java b/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java
index a89cb48c37..729c431d2b 100644
--- a/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/CancellableThreadsTests.java
@@ -132,7 +132,7 @@ public class CancellableThreadsTests extends ESTestCase {
public void testCancellableThreads() throws InterruptedException {
Thread[] threads = new Thread[randomIntBetween(3, 10)];
final TestPlan[] plans = new TestPlan[threads.length];
- final Throwable[] throwables = new Throwable[threads.length];
+ final Exception[] exceptions = new Exception[threads.length];
final boolean[] interrupted = new boolean[threads.length];
final CancellableThreads cancellableThreads = new CancellableThreads();
final CountDownLatch readyForCancel = new CountDownLatch(threads.length);
@@ -153,8 +153,8 @@ public class CancellableThreadsTests extends ESTestCase {
} else {
cancellableThreads.execute(new TestRunnable(plan, readyForCancel));
}
- } catch (Throwable t) {
- throwables[plan.id] = t;
+ } catch (Exception e) {
+ exceptions[plan.id] = e;
}
if (plan.exceptBeforeCancel || plan.exitBeforeCancel) {
// we have to mark we're ready now (actually done).
@@ -176,19 +176,19 @@ public class CancellableThreadsTests extends ESTestCase {
TestPlan plan = plans[i];
final Class<?> exceptionClass = plan.ioException ? IOCustomException.class : CustomException.class;
if (plan.exceptBeforeCancel) {
- assertThat(throwables[i], Matchers.instanceOf(exceptionClass));
+ assertThat(exceptions[i], Matchers.instanceOf(exceptionClass));
} else if (plan.exitBeforeCancel) {
- assertNull(throwables[i]);
+ assertNull(exceptions[i]);
} else {
// in all other cases, we expect a cancellation exception.
- assertThat(throwables[i], Matchers.instanceOf(CancellableThreads.ExecutionCancelledException.class));
+ assertThat(exceptions[i], Matchers.instanceOf(CancellableThreads.ExecutionCancelledException.class));
if (plan.exceptAfterCancel) {
- assertThat(throwables[i].getSuppressed(),
+ assertThat(exceptions[i].getSuppressed(),
Matchers.arrayContaining(
Matchers.instanceOf(exceptionClass)
));
} else {
- assertThat(throwables[i].getSuppressed(), Matchers.emptyArray());
+ assertThat(exceptions[i].getSuppressed(), Matchers.emptyArray());
}
}
assertThat(interrupted[plan.id], Matchers.equalTo(plan.presetInterrupt));
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractLifecycleRunnableTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractLifecycleRunnableTests.java
index 4c2e470094..02adb78319 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractLifecycleRunnableTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractLifecycleRunnableTests.java
@@ -48,7 +48,7 @@ public class AbstractLifecycleRunnableTests extends ESTestCase {
AbstractLifecycleRunnable runnable = new AbstractLifecycleRunnable(lifecycle, logger) {
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
fail("It should not fail");
}
@@ -77,7 +77,7 @@ public class AbstractLifecycleRunnableTests extends ESTestCase {
AbstractLifecycleRunnable runnable = new AbstractLifecycleRunnable(lifecycle, logger) {
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
fail("It should not fail");
}
@@ -106,7 +106,7 @@ public class AbstractLifecycleRunnableTests extends ESTestCase {
AbstractLifecycleRunnable runnable = new AbstractLifecycleRunnable(lifecycle, logger) {
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
fail("It should not fail");
}
@@ -145,7 +145,7 @@ public class AbstractLifecycleRunnableTests extends ESTestCase {
AbstractLifecycleRunnable runnable = new AbstractLifecycleRunnable(lifecycle, logger) {
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
fail("It should not fail");
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractRunnableTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractRunnableTests.java
index 54491aade6..2373b30e1b 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractRunnableTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/AbstractRunnableTests.java
@@ -37,8 +37,8 @@ public class AbstractRunnableTests extends ESTestCase {
AbstractRunnable runnable = new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- fail("It should not fail");
+ public void onFailure(Exception e) {
+ fail(e.toString());
}
@Override
@@ -57,8 +57,8 @@ public class AbstractRunnableTests extends ESTestCase {
AbstractRunnable runnable = new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- assertSame(exception, t);
+ public void onFailure(Exception e) {
+ assertSame(exception, e);
}
@Override
@@ -76,8 +76,8 @@ public class AbstractRunnableTests extends ESTestCase {
AbstractRunnable runnable = new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- fail("It should not fail");
+ public void onFailure(Exception e) {
+ fail(e.toString());
}
@Override
@@ -91,7 +91,7 @@ public class AbstractRunnableTests extends ESTestCase {
afterCallable.call();
}
catch (Exception e) {
- fail("Unexpected for mock.");
+ fail(e.toString());
}
}
};
@@ -111,8 +111,8 @@ public class AbstractRunnableTests extends ESTestCase {
AbstractRunnable runnable = new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- assertSame(exception, t);
+ public void onFailure(Exception e) {
+ assertSame(exception, e);
}
@Override
@@ -126,7 +126,7 @@ public class AbstractRunnableTests extends ESTestCase {
afterCallable.call();
}
catch (Exception e) {
- fail("Unexpected for mock.");
+ fail(e.toString());
}
}
};
@@ -142,14 +142,15 @@ public class AbstractRunnableTests extends ESTestCase {
AbstractRunnable runnable = new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- assertSame(exception, t);
+ public void onFailure(Exception e) {
+ assertSame(exception, e);
try {
failureCallable.call();
}
- catch (Exception e) {
- fail("Unexpected for mock.");
+ catch (Exception inner) {
+ inner.addSuppressed(e);
+ fail(inner.toString());
}
}
@@ -165,8 +166,8 @@ public class AbstractRunnableTests extends ESTestCase {
public void testIsForceExecutuonDefaultsFalse() {
AbstractRunnable runnable = new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- fail("Not tested");
+ public void onFailure(Exception e) {
+ fail(e.toString());
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java
index 57da614e68..72db2911fc 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/EsExecutorsTests.java
@@ -88,8 +88,8 @@ public class EsExecutorsTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
- throw new AssertionError(t);
+ public void onFailure(Exception e) {
+ throw new AssertionError(e);
}
});
@@ -178,7 +178,7 @@ public class EsExecutorsTests extends ESTestCase {
try {
barrier.await();
barrier.await();
- } catch (Throwable e) {
+ } catch (Exception e) {
barrier.reset(e);
}
}
@@ -214,7 +214,7 @@ public class EsExecutorsTests extends ESTestCase {
try {
barrier.await();
barrier.await();
- } catch (Throwable e) {
+ } catch (Exception e) {
barrier.reset(e);
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java
index 9338beccb9..c5d0ec4257 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/RefCountedTests.java
@@ -88,7 +88,7 @@ public class RefCountedTests extends ESTestCase {
final MyRefCounted counted = new MyRefCounted();
Thread[] threads = new Thread[randomIntBetween(2, 5)];
final CountDownLatch latch = new CountDownLatch(1);
- final CopyOnWriteArrayList<Throwable> exceptions = new CopyOnWriteArrayList<>();
+ final CopyOnWriteArrayList<Exception> exceptions = new CopyOnWriteArrayList<>();
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread() {
@Override
@@ -103,7 +103,7 @@ public class RefCountedTests extends ESTestCase {
counted.decRef();
}
}
- } catch (Throwable e) {
+ } catch (Exception e) {
exceptions.add(e);
}
}
diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/ThreadContextTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/ThreadContextTests.java
index d6797d4be2..e672687951 100644
--- a/core/src/test/java/org/elasticsearch/common/util/concurrent/ThreadContextTests.java
+++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/ThreadContextTests.java
@@ -294,8 +294,8 @@ public class ThreadContextTests extends ESTestCase {
}
return new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- throw new RuntimeException(t);
+ public void onFailure(Exception e) {
+ throw new RuntimeException(e);
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java
index f359293676..bef4a047ef 100644
--- a/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java
+++ b/core/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java
@@ -68,7 +68,7 @@ public class ConstructingObjectParserTests extends ESTestCase {
assertEquals(expected.b, parsed.b);
assertEquals(expected.c, parsed.c);
assertEquals(expected.d, parsed.d);
- } catch (Throwable e) {
+ } catch (Exception e) {
// It is convenient to decorate the error message with the json
throw new Exception("Error parsing: [" + builder.string() + "]", e);
}
diff --git a/core/src/test/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandlerTests.java b/core/src/test/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandlerTests.java
index bb38e32910..0f34ff181a 100644
--- a/core/src/test/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandlerTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandlerTests.java
@@ -58,8 +58,8 @@ public class BlockingClusterStatePublishResponseHandlerTests extends ESTestCase
}
@Override
- public void onFailure(Throwable t) {
- logger.error("unexpected error", t);
+ public void onFailure(Exception e) {
+ logger.error("unexpected error", e);
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java
index 13e19e8497..a1bac928da 100644
--- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java
+++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java
@@ -503,8 +503,8 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
}
} catch (InterruptedException e) {
// fine - semaphore interrupt
- } catch (Throwable t) {
- logger.info("unexpected exception in background thread of [{}]", t, node);
+ } catch (AssertionError | Exception e) {
+ logger.info("unexpected exception in background thread of [{}]", e, node);
}
}
});
@@ -690,8 +690,8 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- logger.warn("failure [{}]", t, source);
+ public void onFailure(String source, Exception e) {
+ logger.warn("failure [{}]", e, source);
}
});
@@ -960,7 +960,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(Exception e) {
success.set(false);
latch.countDown();
assert false;
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java
index 9825cd3284..531b20aa3c 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/NodeJoinControllerTests.java
@@ -196,9 +196,9 @@ public class NodeJoinControllerTests extends ESTestCase {
final SimpleFuture electionFuture = new SimpleFuture("master election");
final Thread masterElection = new Thread(new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- logger.error("unexpected error from waitToBeElectedAsMaster", t);
- electionFuture.markAsFailed(t);
+ public void onFailure(Exception e) {
+ logger.error("unexpected error from waitToBeElectedAsMaster", e);
+ electionFuture.markAsFailed(e);
}
@Override
@@ -244,9 +244,9 @@ public class NodeJoinControllerTests extends ESTestCase {
final SimpleFuture electionFuture = new SimpleFuture("master election");
final Thread masterElection = new Thread(new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- logger.error("unexpected error from waitToBeElectedAsMaster", t);
- electionFuture.markAsFailed(t);
+ public void onFailure(Exception e) {
+ logger.error("unexpected error from waitToBeElectedAsMaster", e);
+ electionFuture.markAsFailed(e);
}
@Override
@@ -425,9 +425,9 @@ public class NodeJoinControllerTests extends ESTestCase {
nodes.add(node);
threads[i] = new Thread(new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- logger.error("unexpected error in join thread", t);
- backgroundExceptions.add(t);
+ public void onFailure(Exception e) {
+ logger.error("unexpected error in join thread", e);
+ backgroundExceptions.add(e);
}
@Override
@@ -468,9 +468,9 @@ public class NodeJoinControllerTests extends ESTestCase {
nodes.add(node);
threads[i] = new Thread(new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- logger.error("unexpected error in join thread", t);
- backgroundExceptions.add(t);
+ public void onFailure(Exception e) {
+ logger.error("unexpected error in join thread", e);
+ backgroundExceptions.add(e);
}
@Override
@@ -587,9 +587,9 @@ public class NodeJoinControllerTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
- logger.error("unexpected error for {}", t, future);
- future.markAsFailed(t);
+ public void onFailure(Exception e) {
+ logger.error("unexpected error for {}", e, future);
+ future.markAsFailed(e);
}
});
return future;
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java
index fd0b11eae0..3d0d9ddd8b 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryIT.java
@@ -261,8 +261,8 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable t) {
- holder.set((IllegalStateException) t);
+ public void onFailure(Exception e) {
+ holder.set((IllegalStateException) e);
}
});
@@ -309,8 +309,8 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable t) {
- holder.set((IllegalStateException) t);
+ public void onFailure(Exception e) {
+ holder.set((IllegalStateException) e);
}
});
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java
index ab9aed6ba4..073e0fe147 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PendingClusterStatesQueueTests.java
@@ -259,8 +259,8 @@ public class PendingClusterStatesQueueTests extends ESTestCase {
}
@Override
- public void onNewClusterStateFailed(Throwable t) {
- failure = t;
+ public void onNewClusterStateFailed(Exception e) {
+ failure = e;
}
}
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java
index 61374cc0d8..8271f2dff7 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateActionTests.java
@@ -797,9 +797,9 @@ public class PublishClusterStateActionTests extends ESTestCase {
}
@Override
- public void onNodeAck(DiscoveryNode node, @Nullable Throwable t) {
- if (t != null) {
- errors.add(new Tuple<>(node, t));
+ public void onNodeAck(DiscoveryNode node, @Nullable Exception e) {
+ if (e != null) {
+ errors.add(new Tuple<>(node, e));
}
countDown.countDown();
}
@@ -910,8 +910,8 @@ public class PublishClusterStateActionTests extends ESTestCase {
}
@Override
- public void sendResponse(Throwable error) throws IOException {
- this.error.set(error);
+ public void sendResponse(Exception exception) throws IOException {
+ this.error.set(exception);
assertThat(response.get(), nullValue());
}
diff --git a/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java b/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java
index ad425d8afc..75bfed8533 100644
--- a/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java
+++ b/core/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java
@@ -22,7 +22,6 @@ import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
-import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils;
@@ -48,8 +47,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileExists;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileNotExists;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.containsString;
@@ -269,9 +266,9 @@ public class NodeEnvironmentTests extends ESTestCase {
if (randomBoolean()) {
Thread t = new Thread(new AbstractRunnable() {
@Override
- public void onFailure(Throwable t) {
- logger.error("unexpected error", t);
- threadException.set(t);
+ public void onFailure(Exception e) {
+ logger.error("unexpected error", e);
+ threadException.set(e);
latch.countDown();
blockLatch.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java b/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java
index 948f482043..c5a386976b 100644
--- a/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/AsyncShardFetchTests.java
@@ -292,7 +292,7 @@ public class AsyncShardFetchTests extends ESTestCase {
} else {
processAsyncFetch(shardId, Collections.singletonList(entry.response), null);
}
- } catch (Throwable e) {
+ } catch (Exception e) {
logger.error("unexpected failure", e);
} finally {
if (entry != null) {
diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java b/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java
index 4999ef5eac..795046ba10 100644
--- a/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java
+++ b/core/src/test/java/org/elasticsearch/gateway/MetaDataWriteDataNodesIT.java
@@ -161,8 +161,8 @@ public class MetaDataWriteDataNodesIT extends ESIntegTestCase {
logger.info("checking if meta state exists...");
try {
assertTrue("Expecting meta state of index " + indexName + " to be on node " + nodeName, getIndicesMetaDataOnNode(nodeName).containsKey(indexName));
- } catch (Throwable t) {
- logger.info("failed to load meta state", t);
+ } catch (Exception e) {
+ logger.info("failed to load meta state", e);
fail("could not load meta state");
}
}
diff --git a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java
index 96e360550a..e64c816c4b 100644
--- a/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java
+++ b/core/src/test/java/org/elasticsearch/gateway/PrimaryShardAllocatorTests.java
@@ -24,7 +24,6 @@ import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
-import org.elasticsearch.snapshots.SnapshotId;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RestoreSource;
@@ -41,6 +40,7 @@ import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.ShardStateMetaData;
import org.elasticsearch.snapshots.Snapshot;
+import org.elasticsearch.snapshots.SnapshotId;
import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Before;
@@ -547,7 +547,7 @@ public class PrimaryShardAllocatorTests extends ESAllocationTestCase {
return addData(node, version, allocationId, primary, null);
}
- public TestAllocator addData(DiscoveryNode node, long version, String allocationId, boolean primary, @Nullable Throwable storeException) {
+ public TestAllocator addData(DiscoveryNode node, long version, String allocationId, boolean primary, @Nullable Exception storeException) {
if (data == null) {
data = new HashMap<>();
}
diff --git a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
index 596714b1c5..f67ee09cf0 100644
--- a/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
+++ b/core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java
@@ -379,7 +379,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
assertThat(gResp2.getField("foo").getValue().toString(), equalTo("bar"));
}
- public void testPrimaryRelocationWithConcurrentIndexing() throws Throwable {
+ public void testPrimaryRelocationWithConcurrentIndexing() throws Exception {
Path dataPath = createTempDir();
Settings nodeSettings = nodeSettings(dataPath);
@@ -408,7 +408,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
final int numPhase2Docs = scaledRandomIntBetween(25, 200);
final CountDownLatch phase1finished = new CountDownLatch(1);
final CountDownLatch phase2finished = new CountDownLatch(1);
- final CopyOnWriteArrayList<Throwable> exceptions = new CopyOnWriteArrayList<>();
+ final CopyOnWriteArrayList<Exception> exceptions = new CopyOnWriteArrayList<>();
Thread thread = new Thread() {
@Override
public void run() {
@@ -418,8 +418,8 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
final IndexResponse indexResponse = client().prepareIndex(IDX, "doc",
Integer.toString(counter.incrementAndGet())).setSource("foo", "bar").get();
assertTrue(indexResponse.isCreated());
- } catch (Throwable t) {
- exceptions.add(t);
+ } catch (Exception e) {
+ exceptions.add(e);
}
final int docCount = counter.get();
if (docCount == numPhase1Docs) {
diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
index 0ecf846265..a3fd266f60 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java
@@ -297,7 +297,7 @@ public class InternalEngineTests extends ESTestCase {
}
Engine.EventListener listener = new Engine.EventListener() {
@Override
- public void onFailedEngine(String reason, @Nullable Throwable t) {
+ public void onFailedEngine(String reason, @Nullable Exception e) {
// we don't need to notify anybody in this test
}
};
@@ -2092,7 +2092,7 @@ public class InternalEngineTests extends ESTestCase {
}
public void testShardNotAvailableExceptionWhenEngineClosedConcurrently() throws IOException, InterruptedException {
- AtomicReference<Throwable> throwable = new AtomicReference<>();
+ AtomicReference<Exception> exception = new AtomicReference<>();
String operation = randomFrom("optimize", "refresh", "flush");
Thread mergeThread = new Thread() {
@Override
@@ -2115,8 +2115,8 @@ public class InternalEngineTests extends ESTestCase {
break;
}
}
- } catch (Throwable t) {
- throwable.set(t);
+ } catch (Exception e) {
+ exception.set(e);
stop = true;
}
}
@@ -2125,8 +2125,8 @@ public class InternalEngineTests extends ESTestCase {
mergeThread.start();
engine.close();
mergeThread.join();
- logger.info("exception caught: ", throwable.get());
- assertTrue("expected an Exception that signals shard is not available", TransportActions.isShardNotAvailableException(throwable.get()));
+ logger.info("exception caught: ", exception.get());
+ assertTrue("expected an Exception that signals shard is not available", TransportActions.isShardNotAvailableException(exception.get()));
}
public void testCurrentTranslogIDisCommitted() throws IOException {
diff --git a/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java
index 39112ed602..672686926b 100644
--- a/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java
+++ b/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java
@@ -242,7 +242,7 @@ public class ShadowEngineTests extends ESTestCase {
}
Engine.EventListener eventListener = new Engine.EventListener() {
@Override
- public void onFailedEngine(String reason, @Nullable Throwable t) {
+ public void onFailedEngine(String reason, @Nullable Exception e) {
// we don't need to notify anybody in this test
}
};
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java
index f9fb5e77b7..9a8815e939 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java
@@ -19,7 +19,6 @@
package org.elasticsearch.index.mapper;
-import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
@@ -116,7 +115,7 @@ public class DynamicMappingDisabledTests extends ESSingleNodeTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
onFailureCalled.set(true);
assertThat(e, instanceOf(IndexNotFoundException.class));
assertEquals(e.getMessage(), "no such index");
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIntegrationIT.java
index 8afdea2745..71628c0612 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingIntegrationIT.java
@@ -96,8 +96,8 @@ public class DynamicMappingIntegrationIT extends ESIntegTestCase {
try {
startLatch.await();
assertTrue(client().prepareIndex("index", "type", id).setSource("field" + id, "bar").get().isCreated());
- } catch (Throwable t) {
- error.compareAndSet(null, t);
+ } catch (Exception e) {
+ error.compareAndSet(null, e);
}
}
});
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java b/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
index c93c181f86..2afeb02499 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/MapperServiceTests.java
@@ -103,7 +103,7 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
// 2. already existing index
IndexService indexService = createIndex("index2");
- expectThrows(ExecutionException.class, () -> {
+ e = expectThrows(ExecutionException.class, () -> {
client().prepareIndex("index1", MapperService.DEFAULT_MAPPING, "2").setSource().execute().get();
});
throwable = ExceptionsHelper.unwrapCause(e.getCause());
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java
index 627f268545..0133d3e594 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/merge/TestMergeMapperTests.java
@@ -159,7 +159,7 @@ public class TestMergeMapperTests extends ESSingleNodeTestCase {
final AtomicBoolean stopped = new AtomicBoolean(false);
final CyclicBarrier barrier = new CyclicBarrier(2);
final AtomicReference<String> lastIntroducedFieldName = new AtomicReference<>();
- final AtomicReference<Throwable> error = new AtomicReference<>();
+ final AtomicReference<Exception> error = new AtomicReference<>();
final Thread updater = new Thread() {
@Override
public void run() {
@@ -173,8 +173,8 @@ public class TestMergeMapperTests extends ESSingleNodeTestCase {
lastIntroducedFieldName.set(fieldName);
mapperService.merge("test", new CompressedXContent(update.toString()), MapperService.MergeReason.MAPPING_UPDATE, false);
}
- } catch (Throwable t) {
- error.set(t);
+ } catch (Exception e) {
+ error.set(e);
} finally {
stopped.set(true);
}
diff --git a/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java b/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java
index 1191806bc8..1c6a973192 100644
--- a/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java
+++ b/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java
@@ -408,7 +408,7 @@ public abstract class ESIndexLevelReplicationTestCase extends ESTestCase {
}
@Override
- public void failShard(String message, Throwable throwable) {
+ public void failShard(String message, Exception exception) {
throw new UnsupportedOperationException();
}
@@ -436,14 +436,14 @@ public abstract class ESIndexLevelReplicationTestCase extends ESTestCase {
.filter(s -> replicaRouting.isSameAllocation(s.routingEntry())).findFirst().get();
TransportIndexAction.executeIndexRequestOnReplica(request, replica);
listener.onResponse(TransportResponse.Empty.INSTANCE);
- } catch (Throwable t) {
+ } catch (Exception t) {
listener.onFailure(t);
}
}
@Override
- public void failShard(ShardRouting replica, ShardRouting primary, String message, Throwable throwable, Runnable onSuccess,
- Consumer<Throwable> onPrimaryDemoted, Consumer<Throwable> onIgnoredFailure) {
+ public void failShard(ShardRouting replica, ShardRouting primary, String message, Exception exception, Runnable onSuccess,
+ Consumer<Exception> onPrimaryDemoted, Consumer<Exception> onIgnoredFailure) {
throw new UnsupportedOperationException();
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java
index 6674d6859a..9bc49ad626 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java
@@ -725,7 +725,7 @@ public class IndexShardTests extends ESSingleNodeTestCase {
}
@Override
- public void postIndex(Engine.Index index, Throwable ex) {
+ public void postIndex(Engine.Index index, Exception ex) {
postIndexException.incrementAndGet();
}
@@ -741,7 +741,7 @@ public class IndexShardTests extends ESSingleNodeTestCase {
}
@Override
- public void postDelete(Engine.Delete delete, Throwable ex) {
+ public void postDelete(Engine.Delete delete, Exception ex) {
postDeleteException.incrementAndGet();
}
@@ -1383,7 +1383,7 @@ public class IndexShardTests extends ESSingleNodeTestCase {
IndexSearcherWrapper wrapper = new IndexSearcherWrapper() {};
shard.close("simon says", false);
AtomicReference<IndexShard> shardRef = new AtomicReference<>();
- List<Throwable> failures = new ArrayList<>();
+ List<Exception> failures = new ArrayList<>();
IndexingOperationListener listener = new IndexingOperationListener() {
@Override
@@ -1393,9 +1393,9 @@ public class IndexShardTests extends ESSingleNodeTestCase {
// this is all IMC needs to do - check current memory and refresh
assertTrue(shardRef.get().getIndexBufferRAMBytesUsed() > 0);
shardRef.get().refresh("test");
- } catch (Throwable t) {
- failures.add(t);
- throw t;
+ } catch (Exception e) {
+ failures.add(e);
+ throw e;
}
}
@@ -1407,9 +1407,9 @@ public class IndexShardTests extends ESSingleNodeTestCase {
// this is all IMC needs to do - check current memory and refresh
assertTrue(shardRef.get().getIndexBufferRAMBytesUsed() > 0);
shardRef.get().refresh("test");
- } catch (Throwable t) {
- failures.add(t);
- throw t;
+ } catch (Exception e) {
+ failures.add(e);
+ throw e;
}
}
};
diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java
index 8d86e64a39..d1cf8b32f5 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java
@@ -51,7 +51,7 @@ public class IndexingOperationListenerTests extends ESTestCase{
}
@Override
- public void postIndex(Engine.Index index, Throwable ex) {
+ public void postIndex(Engine.Index index, Exception ex) {
postIndexException.incrementAndGet();
}
@@ -67,7 +67,7 @@ public class IndexingOperationListenerTests extends ESTestCase{
}
@Override
- public void postDelete(Engine.Delete delete, Throwable ex) {
+ public void postDelete(Engine.Delete delete, Exception ex) {
postDeleteException.incrementAndGet();
}
};
@@ -83,7 +83,7 @@ public class IndexingOperationListenerTests extends ESTestCase{
throw new RuntimeException(); }
@Override
- public void postIndex(Engine.Index index, Throwable ex) {
+ public void postIndex(Engine.Index index, Exception ex) {
throw new RuntimeException(); }
@Override
@@ -96,7 +96,7 @@ public class IndexingOperationListenerTests extends ESTestCase{
throw new RuntimeException(); }
@Override
- public void postDelete(Engine.Delete delete, Throwable ex) {
+ public void postDelete(Engine.Delete delete, Exception ex) {
throw new RuntimeException();
}
};
diff --git a/core/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java b/core/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java
index 4938f686f6..79b0773481 100644
--- a/core/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java
+++ b/core/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java
@@ -115,7 +115,7 @@ public class RefreshListenersTests extends ESTestCase {
BigArrays.NON_RECYCLING_INSTANCE);
Engine.EventListener eventListener = new Engine.EventListener() {
@Override
- public void onFailedEngine(String reason, @Nullable Throwable t) {
+ public void onFailedEngine(String reason, @Nullable Exception e) {
// we don't need to notify anybody in this test
}
};
@@ -251,7 +251,7 @@ public class RefreshListenersTests extends ESTestCase {
getResult.docIdAndVersion().context.reader().document(getResult.docIdAndVersion().docId, visitor);
assertEquals(Arrays.asList(testFieldValue), visitor.fields().get("test"));
}
- } catch (Throwable t) {
+ } catch (Exception t) {
throw new RuntimeException("failure on the [" + iteration + "] iteration of thread [" + threadId + "]", t);
}
}
@@ -279,7 +279,7 @@ public class RefreshListenersTests extends ESTestCase {
document.add(uidField);
document.add(versionField);
BytesReference source = new BytesArray(new byte[] { 1 });
- ParsedDocument doc = new ParsedDocument(versionField, id, type, null, -1, -1, Arrays.asList(document), source, null);
+ ParsedDocument doc = new ParsedDocument(versionField, id, type, null, -1, -1, Arrays.asList(document), source, null);
Engine.Index index = new Engine.Index(new Term("_uid", uid), doc);
engine.index(index);
return index;
@@ -290,7 +290,7 @@ public class RefreshListenersTests extends ESTestCase {
* When the listener is called this captures it's only argument.
*/
AtomicReference<Boolean> forcedRefresh = new AtomicReference<>();
- private volatile Throwable error;
+ private volatile Exception error;
@Override
public void accept(Boolean forcedRefresh) {
@@ -298,7 +298,7 @@ public class RefreshListenersTests extends ESTestCase {
assertNotNull(forcedRefresh);
Boolean oldValue = this.forcedRefresh.getAndSet(forcedRefresh);
assertNull("Listener called twice", oldValue);
- } catch (Throwable e) {
+ } catch (Exception e) {
error = e;
}
}
diff --git a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
index 84d50c6620..eb70069b0b 100644
--- a/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
+++ b/core/src/test/java/org/elasticsearch/index/store/CorruptedFileIT.java
@@ -193,7 +193,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
* run the checkindex. if the corruption is still there we will catch it.
*/
final CountDownLatch latch = new CountDownLatch(numShards * 3); // primary + 2 replicas
- final CopyOnWriteArrayList<Throwable> exception = new CopyOnWriteArrayList<>();
+ final CopyOnWriteArrayList<Exception> exception = new CopyOnWriteArrayList<>();
final IndexEventListener listener = new IndexEventListener() {
@Override
public void afterIndexShardClosed(ShardId sid, @Nullable IndexShard indexShard, Settings indexSettings) {
@@ -215,8 +215,8 @@ public class CorruptedFileIT extends ESIntegTestCase {
throw new IOException("index check failure");
}
}
- } catch (Throwable t) {
- exception.add(t);
+ } catch (Exception e) {
+ exception.add(e);
} finally {
store.decRef();
latch.countDown();
diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
index 01eead9c96..c9b3daa806 100644
--- a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
+++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java
@@ -20,7 +20,6 @@
package org.elasticsearch.index.translog;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
-
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.Term;
import org.apache.lucene.mockfile.FilterFileChannel;
@@ -456,7 +455,7 @@ public class TranslogTests extends ESTestCase {
final BlockingQueue<LocationOperation> writtenOperations = new ArrayBlockingQueue<>(threadCount * opsPerThread);
Thread[] threads = new Thread[threadCount];
- final Throwable[] threadExceptions = new Throwable[threadCount];
+ final Exception[] threadExceptions = new Exception[threadCount];
final CountDownLatch downLatch = new CountDownLatch(1);
for (int i = 0; i < threadCount; i++) {
final int threadId = i;
@@ -624,7 +623,7 @@ public class TranslogTests extends ESTestCase {
final AtomicBoolean run = new AtomicBoolean(true);
// any errors on threads
- final List<Throwable> errors = new CopyOnWriteArrayList<>();
+ final List<Exception> errors = new CopyOnWriteArrayList<>();
logger.debug("using [{}] readers. [{}] writers. flushing every ~[{}] ops.", readers.length, writers.length, flushEveryOps);
for (int i = 0; i < writers.length; i++) {
final String threadName = "writer_" + i;
@@ -663,9 +662,9 @@ public class TranslogTests extends ESTestCase {
}
@Override
- public void onFailure(Throwable t) {
- logger.error("--> writer [{}] had an error", t, threadName);
- errors.add(t);
+ public void onFailure(Exception e) {
+ logger.error("--> writer [{}] had an error", e, threadName);
+ errors.add(e);
}
}, threadName);
writers[i].start();
@@ -678,14 +677,14 @@ public class TranslogTests extends ESTestCase {
Set<Translog.Operation> writtenOpsAtView;
@Override
- public void onFailure(Throwable t) {
- logger.error("--> reader [{}] had an error", t, threadId);
- errors.add(t);
+ public void onFailure(Exception e) {
+ logger.error("--> reader [{}] had an error", e, threadId);
+ errors.add(e);
try {
closeView();
- } catch (IOException e) {
- logger.error("unexpected error while closing view, after failure");
- t.addSuppressed(e);
+ } catch (IOException inner) {
+ inner.addSuppressed(e);
+ logger.error("unexpected error while closing view, after failure", inner);
}
}
@@ -1240,7 +1239,7 @@ public class TranslogTests extends ESTestCase {
final BlockingQueue<LocationOperation> writtenOperations = new ArrayBlockingQueue<>(threadCount * opsPerThread);
Thread[] threads = new Thread[threadCount];
- final Throwable[] threadExceptions = new Throwable[threadCount];
+ final Exception[] threadExceptions = new Exception[threadCount];
final CountDownLatch downLatch = new CountDownLatch(1);
for (int i = 0; i < threadCount; i++) {
final int threadId = i;
@@ -1267,10 +1266,10 @@ public class TranslogTests extends ESTestCase {
private final int opsPerThread;
private final int threadId;
private final Collection<LocationOperation> writtenOperations;
- private final Throwable[] threadExceptions;
+ private final Exception[] threadExceptions;
private final Translog translog;
- public TranslogThread(Translog translog, CountDownLatch downLatch, int opsPerThread, int threadId, Collection<LocationOperation> writtenOperations, Throwable[] threadExceptions) {
+ public TranslogThread(Translog translog, CountDownLatch downLatch, int opsPerThread, int threadId, Collection<LocationOperation> writtenOperations, Exception[] threadExceptions) {
this.translog = translog;
this.downLatch = downLatch;
this.opsPerThread = opsPerThread;
@@ -1304,7 +1303,7 @@ public class TranslogTests extends ESTestCase {
writtenOperations.add(new LocationOperation(op, loc));
afterAdd();
}
- } catch (Throwable t) {
+ } catch (Exception t) {
threadExceptions[threadId] = t;
}
}
@@ -1446,7 +1445,7 @@ public class TranslogTests extends ESTestCase {
final int threadCount = randomIntBetween(1, 5);
Thread[] threads = new Thread[threadCount];
- final Throwable[] threadExceptions = new Throwable[threadCount];
+ final Exception[] threadExceptions = new Exception[threadCount];
final CountDownLatch downLatch = new CountDownLatch(1);
final CountDownLatch added = new CountDownLatch(randomIntBetween(10, 100));
List<LocationOperation> writtenOperations = Collections.synchronizedList(new ArrayList<>());
diff --git a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java
index 23925f574f..60e062c0d1 100644
--- a/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java
+++ b/core/src/test/java/org/elasticsearch/indexing/IndexActionIT.java
@@ -50,7 +50,7 @@ public class IndexActionIT extends ESIntegTestCase {
public void testAutoGenerateIdNoDuplicates() throws Exception {
int numberOfIterations = scaledRandomIntBetween(10, 50);
for (int i = 0; i < numberOfIterations; i++) {
- Throwable firstError = null;
+ Exception firstError = null;
createIndex("test");
int numOfDocs = randomIntBetween(10, 100);
logger.info("indexing [{}] docs", numOfDocs);
@@ -66,19 +66,19 @@ public class IndexActionIT extends ESIntegTestCase {
try {
logger.debug("running search with all types");
assertHitCount(client().prepareSearch("test").get(), numOfDocs);
- } catch (Throwable t) {
- logger.error("search for all docs types failed", t);
+ } catch (Exception e) {
+ logger.error("search for all docs types failed", e);
if (firstError == null) {
- firstError = t;
+ firstError = e;
}
}
try {
logger.debug("running search with a specific type");
assertHitCount(client().prepareSearch("test").setTypes("type").get(), numOfDocs);
- } catch (Throwable t) {
- logger.error("search for all docs of a specific type failed", t);
+ } catch (Exception e) {
+ logger.error("search for all docs of a specific type failed", e);
if (firstError == null) {
- firstError = t;
+ firstError = e;
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java b/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java
index 4312dd6105..5e636bed93 100644
--- a/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java
@@ -456,9 +456,9 @@ public class AnalyzeActionIT extends ESIntegTestCase {
.setAnalyzer("not_exist_analyzer")
.get();
fail("shouldn't get here");
- } catch (Throwable t) {
- assertThat(t, instanceOf(IllegalArgumentException.class));
- assertThat(t.getMessage(), startsWith("failed to find global analyzer"));
+ } catch (Exception e) {
+ assertThat(e, instanceOf(IllegalArgumentException.class));
+ assertThat(e.getMessage(), startsWith("failed to find global analyzer"));
}
diff --git a/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java b/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java
index 8c724efdfc..5f7f26cd38 100644
--- a/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/flush/FlushIT.java
@@ -68,14 +68,14 @@ public class FlushIT extends ESIntegTestCase {
// don't use assertAllSuccessful it uses a randomized context that belongs to a different thread
assertThat("Unexpected ShardFailures: " + Arrays.toString(flushResponse.getShardFailures()), flushResponse.getFailedShards(), equalTo(0));
latch.countDown();
- } catch (Throwable ex) {
+ } catch (Exception ex) {
onFailure(ex);
}
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
errors.add(e);
latch.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushUtil.java b/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushUtil.java
index 485ec020c3..b71ba63a15 100644
--- a/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushUtil.java
+++ b/core/src/test/java/org/elasticsearch/indices/flush/SyncedFlushUtil.java
@@ -57,7 +57,7 @@ public class SyncedFlushUtil {
public static final class LatchedListener<T> implements ActionListener<T> {
public volatile T result;
- public volatile Throwable error;
+ public volatile Exception error;
public final CountDownLatch latch = new CountDownLatch(1);
@Override
@@ -67,7 +67,7 @@ public class SyncedFlushUtil {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
error = e;
latch.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java
index 2981f2d110..eeaeb84d9a 100644
--- a/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/mapping/ConcurrentDynamicTemplateIT.java
@@ -69,7 +69,7 @@ public class ConcurrentDynamicTemplateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
throwable.add(e);
latch.countDown();
}
@@ -83,4 +83,4 @@ public class ConcurrentDynamicTemplateIT extends ESIntegTestCase {
}
}
-} \ No newline at end of file
+}
diff --git a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
index 68a176e22c..91fd7bb972 100644
--- a/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
@@ -43,6 +43,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
@@ -258,7 +259,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
// not all shards are allocated with the initial create index. Wait for it..
ensureYellow();
- final Throwable[] threadException = new Throwable[1];
+ final AtomicReference<Exception> threadException = new AtomicReference<>();
final AtomicBoolean stop = new AtomicBoolean(false);
Thread[] threads = new Thread[3];
final CyclicBarrier barrier = new CyclicBarrier(threads.length);
@@ -298,8 +299,8 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
assertThat(mappings.containsKey(typeName), equalTo(true));
assertThat(((Map<String, Object>) mappings.get(typeName).getSourceAsMap().get("properties")).keySet(), Matchers.hasItem(fieldName));
}
- } catch (Throwable t) {
- threadException[0] = t;
+ } catch (Exception e) {
+ threadException.set(e);
stop.set(true);
}
}
@@ -311,8 +312,8 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
for (Thread t : threads) t.join();
- if (threadException[0] != null) {
- throw threadException[0];
+ if (threadException.get() != null) {
+ throw threadException.get();
}
}
diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java
index bcd614121b..c59eea6af6 100644
--- a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java
+++ b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryTargetTests.java
@@ -59,7 +59,7 @@ public class RecoveryTargetTests extends ESTestCase {
private T lastRead;
private final AtomicBoolean shouldStop;
private final T source;
- final AtomicReference<Throwable> error = new AtomicReference<>();
+ final AtomicReference<Exception> error = new AtomicReference<>();
final Version streamVersion;
Streamer(AtomicBoolean shouldStop, T source) {
@@ -73,7 +73,7 @@ public class RecoveryTargetTests extends ESTestCase {
}
public T lastRead() throws Throwable {
- Throwable t = error.get();
+ Exception t = error.get();
if (t != null) {
throw t;
}
@@ -105,8 +105,8 @@ public class RecoveryTargetTests extends ESTestCase {
serializeDeserialize();
}
serializeDeserialize();
- } catch (Throwable t) {
- error.set(t);
+ } catch (Exception e) {
+ error.set(e);
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java
index 81c50cc4f9..a5b8bf6342 100644
--- a/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/state/RareClusterStateIT.java
@@ -145,7 +145,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
}
});
@@ -165,7 +165,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
}
});
@@ -260,7 +260,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
putMappingResponse.set(e);
}
});
@@ -292,7 +292,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
docIndexResponse.set(e);
}
});
@@ -376,7 +376,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
putMappingResponse.set(e);
}
});
@@ -403,7 +403,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
docIndexResponse.set(e);
}
});
diff --git a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
index b4f66c2e17..ad26ec7122 100644
--- a/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
+++ b/core/src/test/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
@@ -426,7 +426,7 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
}
});
waitNoPendingTasksOnAll();
diff --git a/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java b/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java
index fcc6e04c6c..53964132ab 100644
--- a/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java
@@ -74,7 +74,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
public void testExecuteIndexPipelineDoesNotExist() {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
try {
@@ -83,7 +83,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), equalTo("pipeline with id [_id] does not exist"));
}
- verify(failureHandler, never()).accept(any(Throwable.class));
+ verify(failureHandler, never()).accept(any(Exception.class));
verify(completionHandler, never()).accept(anyBoolean());
}
@@ -98,9 +98,9 @@ public class PipelineExecutionServiceTests extends ESTestCase {
new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("does_not_exist");
bulkRequest.add(indexRequest2);
@SuppressWarnings("unchecked")
- BiConsumer<IndexRequest, Throwable> failureHandler = mock(BiConsumer.class);
+ BiConsumer<IndexRequest, Exception> failureHandler = mock(BiConsumer.class);
@SuppressWarnings("unchecked")
- Consumer<Throwable> completionHandler = mock(Consumer.class);
+ Consumer<Exception> completionHandler = mock(Consumer.class);
executionService.executeBulkRequest(bulkRequest.requests(), failureHandler, completionHandler);
verify(failureHandler, times(1)).accept(
argThat(new CustomTypeSafeMatcher<IndexRequest>("failure handler was not called with the expected arguments") {
@@ -126,7 +126,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -141,7 +141,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -169,7 +169,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -193,7 +193,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
doThrow(new RuntimeException()).when(processor).execute(eqID("_index", "_type", "_id", Collections.emptyMap()));
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -213,7 +213,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
doThrow(new RuntimeException()).when(processor).execute(eqID("_index", "_type", "_id", Collections.emptyMap()));
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -231,7 +231,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
doThrow(new RuntimeException()).when(processor).execute(eqID("_index", "_type", "_id", Collections.emptyMap()));
doThrow(new RuntimeException()).when(onFailureProcessor).execute(eqID("_index", "_type", "_id", Collections.emptyMap()));
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -253,7 +253,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
doThrow(new RuntimeException()).when(onFailureProcessor).execute(eqID("_index", "_type", "_id", Collections.emptyMap()));
doThrow(new RuntimeException()).when(processor).execute(eqID("_index", "_type", "_id", Collections.emptyMap()));
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -268,7 +268,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -284,7 +284,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").source(Collections.emptyMap()).setPipeline("_id");
@SuppressWarnings("unchecked")
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
@SuppressWarnings("unchecked")
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -298,7 +298,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
IndexRequest indexRequest = new IndexRequest("_index", "_type", "_id").setPipeline("_id")
.source(Collections.emptyMap())
.ttl(1000L);
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
Consumer<Boolean> completionHandler = mock(Consumer.class);
executionService.executeIndexRequest(indexRequest, failureHandler, completionHandler);
@@ -336,8 +336,8 @@ public class PipelineExecutionServiceTests extends ESTestCase {
doThrow(error).when(processor).execute(any());
when(store.get(pipelineId)).thenReturn(new Pipeline(pipelineId, null, processor));
- BiConsumer<IndexRequest, Throwable> requestItemErrorHandler = mock(BiConsumer.class);
- Consumer<Throwable> completionHandler = mock(Consumer.class);
+ BiConsumer<IndexRequest, Exception> requestItemErrorHandler = mock(BiConsumer.class);
+ Consumer<Exception> completionHandler = mock(Consumer.class);
executionService.executeBulkRequest(bulkRequest.requests(), requestItemErrorHandler, completionHandler);
verify(requestItemErrorHandler, times(numIndexRequests)).accept(any(IndexRequest.class), eq(error));
@@ -358,9 +358,9 @@ public class PipelineExecutionServiceTests extends ESTestCase {
when(store.get(pipelineId)).thenReturn(new Pipeline(pipelineId, null, new CompoundProcessor()));
@SuppressWarnings("unchecked")
- BiConsumer<IndexRequest, Throwable> requestItemErrorHandler = mock(BiConsumer.class);
+ BiConsumer<IndexRequest, Exception> requestItemErrorHandler = mock(BiConsumer.class);
@SuppressWarnings("unchecked")
- Consumer<Throwable> completionHandler = mock(Consumer.class);
+ Consumer<Exception> completionHandler = mock(Consumer.class);
executionService.executeBulkRequest(bulkRequest.requests(), requestItemErrorHandler, completionHandler);
verify(requestItemErrorHandler, never()).accept(any(), any());
@@ -383,7 +383,7 @@ public class PipelineExecutionServiceTests extends ESTestCase {
configurationMap.put("_id2", new PipelineConfiguration("_id2", new BytesArray("{}")));
executionService.updatePipelineStats(new IngestMetadata(configurationMap));
- Consumer<Throwable> failureHandler = mock(Consumer.class);
+ Consumer<Exception> failureHandler = mock(Consumer.class);
Consumer<Boolean> completionHandler = mock(Consumer.class);
IndexRequest indexRequest = new IndexRequest("_index");
diff --git a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java
index a1f4d38191..94a56d1193 100644
--- a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java
+++ b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java
@@ -54,9 +54,9 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
public void testNegativeSetting() throws InterruptedException {
String collector = randomAsciiOfLength(5);
Settings settings = Settings.builder().put("monitor.jvm.gc.collector." + collector + ".warn", "-" + randomTimeValue()).build();
- execute(settings, (command, interval) -> null, t -> {
- assertThat(t, instanceOf(IllegalArgumentException.class));
- assertThat(t.getMessage(), allOf(containsString("invalid gc_threshold"), containsString("for [monitor.jvm.gc.collector." + collector + ".")));
+ execute(settings, (command, interval) -> null, e -> {
+ assertThat(e, instanceOf(IllegalArgumentException.class));
+ assertThat(e.getMessage(), allOf(containsString("invalid gc_threshold"), containsString("for [monitor.jvm.gc.collector." + collector + ".")));
}, true, null);
}
@@ -74,9 +74,9 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
}
// we should get an exception that a setting is missing
- execute(builder.build(), (command, interval) -> null, t -> {
- assertThat(t, instanceOf(IllegalArgumentException.class));
- assertThat(t.getMessage(), containsString("missing gc_threshold for [monitor.jvm.gc.collector." + collector + "."));
+ execute(builder.build(), (command, interval) -> null, e -> {
+ assertThat(e, instanceOf(IllegalArgumentException.class));
+ assertThat(e.getMessage(), containsString("missing gc_threshold for [monitor.jvm.gc.collector." + collector + "."));
}, true, null);
}
@@ -84,18 +84,18 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
for (final String threshold : new String[] { "warn", "info", "debug" }) {
final Settings.Builder builder = Settings.builder();
builder.put("monitor.jvm.gc.overhead." + threshold, randomIntBetween(Integer.MIN_VALUE, -1));
- execute(builder.build(), (command, interval) -> null, t -> {
- assertThat(t, instanceOf(IllegalArgumentException.class));
- assertThat(t.getMessage(), containsString("setting [monitor.jvm.gc.overhead." + threshold + "] must be >= 0"));
+ execute(builder.build(), (command, interval) -> null, e -> {
+ assertThat(e, instanceOf(IllegalArgumentException.class));
+ assertThat(e.getMessage(), containsString("setting [monitor.jvm.gc.overhead." + threshold + "] must be >= 0"));
}, true, null);
}
for (final String threshold : new String[] { "warn", "info", "debug" }) {
final Settings.Builder builder = Settings.builder();
builder.put("monitor.jvm.gc.overhead." + threshold, randomIntBetween(100 + 1, Integer.MAX_VALUE));
- execute(builder.build(), (command, interval) -> null, t -> {
- assertThat(t, instanceOf(IllegalArgumentException.class));
- assertThat(t.getMessage(), containsString("setting [monitor.jvm.gc.overhead." + threshold + "] must be <= 100"));
+ execute(builder.build(), (command, interval) -> null, e -> {
+ assertThat(e, instanceOf(IllegalArgumentException.class));
+ assertThat(e.getMessage(), containsString("setting [monitor.jvm.gc.overhead." + threshold + "] must be <= 100"));
}, true, null);
}
@@ -104,9 +104,9 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
infoWarnOutOfOrderBuilder.put("monitor.jvm.gc.overhead.info", info);
final int warn = randomIntBetween(1, info - 1);
infoWarnOutOfOrderBuilder.put("monitor.jvm.gc.overhead.warn", warn);
- execute(infoWarnOutOfOrderBuilder.build(), (command, interval) -> null, t -> {
- assertThat(t, instanceOf(IllegalArgumentException.class));
- assertThat(t.getMessage(), containsString("[monitor.jvm.gc.overhead.warn] must be greater than [monitor.jvm.gc.overhead.info] [" + info + "] but was [" + warn + "]"));
+ execute(infoWarnOutOfOrderBuilder.build(), (command, interval) -> null, e -> {
+ assertThat(e, instanceOf(IllegalArgumentException.class));
+ assertThat(e.getMessage(), containsString("[monitor.jvm.gc.overhead.warn] must be greater than [monitor.jvm.gc.overhead.info] [" + info + "] but was [" + warn + "]"));
}, true, null);
final Settings.Builder debugInfoOutOfOrderBuilder = Settings.builder();
@@ -114,9 +114,9 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
final int debug = randomIntBetween(info + 1, 99);
debugInfoOutOfOrderBuilder.put("monitor.jvm.gc.overhead.debug", debug);
debugInfoOutOfOrderBuilder.put("monitor.jvm.gc.overhead.warn", randomIntBetween(debug + 1, 100)); // or the test will fail for the wrong reason
- execute(debugInfoOutOfOrderBuilder.build(), (command, interval) -> null, t -> {
- assertThat(t, instanceOf(IllegalArgumentException.class));
- assertThat(t.getMessage(), containsString("[monitor.jvm.gc.overhead.info] must be greater than [monitor.jvm.gc.overhead.debug] [" + debug + "] but was [" + info + "]"));
+ execute(debugInfoOutOfOrderBuilder.build(), (command, interval) -> null, e -> {
+ assertThat(e, instanceOf(IllegalArgumentException.class));
+ assertThat(e.getMessage(), containsString("[monitor.jvm.gc.overhead.info] must be greater than [monitor.jvm.gc.overhead.debug] [" + debug + "] but was [" + info + "]"));
}, true, null);
}
@@ -124,7 +124,7 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
execute(settings, scheduler, null, false, asserts);
}
- private static void execute(Settings settings, BiFunction<Runnable, TimeValue, ScheduledFuture<?>> scheduler, Consumer<Throwable> consumer, boolean constructionShouldFail, Runnable asserts) throws InterruptedException {
+ private static void execute(Settings settings, BiFunction<Runnable, TimeValue, ScheduledFuture<?>> scheduler, Consumer<Exception> consumer, boolean constructionShouldFail, Runnable asserts) throws InterruptedException {
assert constructionShouldFail == (consumer != null);
assert constructionShouldFail == (asserts == null);
ThreadPool threadPool = null;
@@ -143,7 +143,7 @@ public class JvmGcMonitorServiceSettingsTests extends ESTestCase {
service.doStart();
asserts.run();
service.doStop();
- } catch (Throwable t) {
+ } catch (Exception t) {
consumer.accept(t);
}
} finally {
diff --git a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmMonitorTests.java b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmMonitorTests.java
index 91862e9cd1..278a47ed21 100644
--- a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmMonitorTests.java
+++ b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmMonitorTests.java
@@ -48,10 +48,10 @@ public class JvmMonitorTests extends ESTestCase {
AtomicBoolean invoked = new AtomicBoolean();
JvmGcMonitorService.JvmMonitor monitor = new JvmGcMonitorService.JvmMonitor(Collections.emptyMap(), IGNORE) {
@Override
- void onMonitorFailure(Throwable t) {
+ void onMonitorFailure(Exception e) {
invoked.set(true);
- assertThat(t, instanceOf(RuntimeException.class));
- assertThat(t, hasToString(containsString("simulated")));
+ assertThat(e, instanceOf(RuntimeException.class));
+ assertThat(e, hasToString(containsString("simulated")));
}
@Override
@@ -174,7 +174,7 @@ public class JvmMonitorTests extends ESTestCase {
JvmGcMonitorService.JvmMonitor monitor = new JvmGcMonitorService.JvmMonitor(gcThresholds, IGNORE) {
@Override
- void onMonitorFailure(Throwable t) {
+ void onMonitorFailure(Exception e) {
}
@Override
@@ -284,7 +284,7 @@ public class JvmMonitorTests extends ESTestCase {
final JvmGcMonitorService.JvmMonitor monitor = new JvmGcMonitorService.JvmMonitor(Collections.emptyMap(), IGNORE) {
@Override
- void onMonitorFailure(Throwable t) {
+ void onMonitorFailure(Exception e) {
}
@Override
@@ -358,7 +358,7 @@ public class JvmMonitorTests extends ESTestCase {
final JvmGcMonitorService.JvmMonitor monitor = new JvmGcMonitorService.JvmMonitor(Collections.emptyMap(), gcOverheadThreshold) {
@Override
- void onMonitorFailure(final Throwable t) {
+ void onMonitorFailure(final Exception e) {
}
@Override
diff --git a/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java b/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java
index 6bb1716cb0..051159b448 100644
--- a/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java
+++ b/core/src/test/java/org/elasticsearch/rest/BytesRestResponseTests.java
@@ -41,11 +41,16 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-/**
- *
- */
public class BytesRestResponseTests extends ESTestCase {
+ class UnknownException extends Exception {
+
+ public UnknownException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ }
+
public void testWithHeaders() throws Exception {
RestRequest request = new FakeRestRequest();
RestChannel channel = randomBoolean() ? new DetailedExceptionRestChannel(request) : new SimpleExceptionRestChannel(request);
@@ -61,7 +66,7 @@ public class BytesRestResponseTests extends ESTestCase {
RestRequest request = new FakeRestRequest();
RestChannel channel = new SimpleExceptionRestChannel(request);
- Throwable t = new ElasticsearchException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
+ Exception t = new ElasticsearchException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
BytesRestResponse response = new BytesRestResponse(channel, t);
String text = response.content().utf8ToString();
assertThat(text, containsString("ElasticsearchException[an error occurred reading data]"));
@@ -74,7 +79,7 @@ public class BytesRestResponseTests extends ESTestCase {
RestRequest request = new FakeRestRequest();
RestChannel channel = new DetailedExceptionRestChannel(request);
- Throwable t = new ElasticsearchException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
+ Exception t = new ElasticsearchException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
BytesRestResponse response = new BytesRestResponse(channel, t);
String text = response.content().utf8ToString();
assertThat(text, containsString("{\"type\":\"exception\",\"reason\":\"an error occurred reading data\"}"));
@@ -85,10 +90,10 @@ public class BytesRestResponseTests extends ESTestCase {
RestRequest request = new FakeRestRequest();
RestChannel channel = new SimpleExceptionRestChannel(request);
- Throwable t = new Throwable("an error occurred reading data", new FileNotFoundException("/foo/bar"));
+ Exception t = new UnknownException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
BytesRestResponse response = new BytesRestResponse(channel, t);
String text = response.content().utf8ToString();
- assertThat(text, not(containsString("Throwable[an error occurred reading data]")));
+ assertThat(text, not(containsString("UnknownException[an error occurred reading data]")));
assertThat(text, not(containsString("FileNotFoundException[/foo/bar]")));
assertThat(text, not(containsString("error_trace")));
assertThat(text, containsString("\"error\":\"No ElasticsearchException found\""));
@@ -99,10 +104,10 @@ public class BytesRestResponseTests extends ESTestCase {
request.params().put("error_trace", "true");
RestChannel channel = new DetailedExceptionRestChannel(request);
- Throwable t = new Throwable("an error occurred reading data", new FileNotFoundException("/foo/bar"));
+ Exception t = new UnknownException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
BytesRestResponse response = new BytesRestResponse(channel, t);
String text = response.content().utf8ToString();
- assertThat(text, containsString("\"type\":\"throwable\",\"reason\":\"an error occurred reading data\""));
+ assertThat(text, containsString("\"type\":\"unknown_exception\",\"reason\":\"an error occurred reading data\""));
assertThat(text, containsString("{\"type\":\"file_not_found_exception\""));
assertThat(text, containsString("\"stack_trace\":\"[an error occurred reading data]"));
}
@@ -111,14 +116,14 @@ public class BytesRestResponseTests extends ESTestCase {
RestRequest request = new FakeRestRequest();
RestChannel channel = new DetailedExceptionRestChannel(request);
{
- Throwable t = new ElasticsearchException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
- BytesRestResponse response = new BytesRestResponse(channel, t);
+ Exception e = new ElasticsearchException("an error occurred reading data", new FileNotFoundException("/foo/bar"));
+ BytesRestResponse response = new BytesRestResponse(channel, e);
String text = response.content().utf8ToString();
assertThat(text, containsString("{\"root_cause\":[{\"type\":\"exception\",\"reason\":\"an error occurred reading data\"}]"));
}
{
- Throwable t = new FileNotFoundException("/foo/bar");
- BytesRestResponse response = new BytesRestResponse(channel, t);
+ Exception e = new FileNotFoundException("/foo/bar");
+ BytesRestResponse response = new BytesRestResponse(channel, e);
String text = response.content().utf8ToString();
assertThat(text, containsString("{\"root_cause\":[{\"type\":\"file_not_found_exception\",\"reason\":\"/foo/bar\"}]"));
}
diff --git a/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java b/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java
index 2bb39ad10e..6542bad5b8 100644
--- a/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java
+++ b/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java
@@ -65,7 +65,7 @@ public class SearchWithRejectionsIT extends ESIntegTestCase {
for (int i = 0; i < numSearches; i++) {
try {
responses[i].get();
- } catch (Throwable t) {
+ } catch (Exception t) {
}
}
awaitBusy(() -> client().admin().indices().prepareStats().execute().actionGet().getTotal().getSearch().getOpenContexts() == 0, 1, TimeUnit.SECONDS);
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java
index a48facc4d6..0c8b9a22c3 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java
@@ -52,9 +52,6 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;
-/**
- *
- */
@ESIntegTestCase.SuiteScopeTestCase
public class FilterIT extends ESIntegTestCase {
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java
index a95df3ff5e..592861ccce 100644
--- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java
+++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java
@@ -58,9 +58,6 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.notNullValue;
-/**
- *
- */
@ESIntegTestCase.SuiteScopeTestCase
public class FiltersIT extends ESIntegTestCase {
diff --git a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
index 98ae3241db..eb6322c151 100644
--- a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
+++ b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
@@ -98,11 +98,11 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase {
if (numberOfReplicas == 1 || !ex.getMessage().contains("all shards failed")) {
thrownExceptions.add(ex);
}
- } catch (Throwable t) {
+ } catch (Exception ex) {
if (!criticalException) {
- nonCriticalExceptions.add(t);
+ nonCriticalExceptions.add(ex);
} else {
- thrownExceptions.add(t);
+ thrownExceptions.add(ex);
}
}
}
diff --git a/core/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java b/core/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java
index 50fb3f9074..bbd1bec1d4 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java
@@ -279,8 +279,8 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase {
}
@Override
- public void onFailure(String source, Throwable t) {
- logger.warn("failed to execute [{}]", t, source);
+ public void onFailure(String source, Exception e) {
+ logger.warn("failed to execute [{}]", e, source);
}
});
diff --git a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
index a25c8e0593..9d571c02c9 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
@@ -272,7 +272,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
}
@Override
- public void onFailure(String source, @Nullable Throwable t) {
+ public void onFailure(String source, @Nullable Exception e) {
countDownLatch.countDown();
}
diff --git a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
index e1efbdfaf8..f604900285 100644
--- a/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
+++ b/core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
@@ -2042,7 +2042,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
}
@Override
- public void onFailure(String source, Throwable t) {
+ public void onFailure(String source, Exception e) {
fail();
}
diff --git a/core/src/test/java/org/elasticsearch/test/geo/RandomShapeGenerator.java b/core/src/test/java/org/elasticsearch/test/geo/RandomShapeGenerator.java
index 897fa44b59..20c82e6f51 100644
--- a/core/src/test/java/org/elasticsearch/test/geo/RandomShapeGenerator.java
+++ b/core/src/test/java/org/elasticsearch/test/geo/RandomShapeGenerator.java
@@ -20,16 +20,9 @@
package org.elasticsearch.test.geo;
import com.carrotsearch.randomizedtesting.generators.RandomInts;
-import org.locationtech.spatial4j.context.jts.JtsSpatialContext;
-import org.locationtech.spatial4j.distance.DistanceUtils;
-import org.locationtech.spatial4j.exception.InvalidShapeException;
-import org.locationtech.spatial4j.shape.Point;
-import org.locationtech.spatial4j.shape.Rectangle;
-import org.locationtech.spatial4j.shape.impl.Range;
import com.vividsolutions.jts.algorithm.ConvexHull;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
-
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.geo.builders.CoordinateCollection;
import org.elasticsearch.common.geo.builders.CoordinatesBuilder;
@@ -42,6 +35,12 @@ import org.elasticsearch.common.geo.builders.PolygonBuilder;
import org.elasticsearch.common.geo.builders.ShapeBuilder;
import org.elasticsearch.search.geo.GeoShapeQueryTests;
import org.junit.Assert;
+import org.locationtech.spatial4j.context.jts.JtsSpatialContext;
+import org.locationtech.spatial4j.distance.DistanceUtils;
+import org.locationtech.spatial4j.exception.InvalidShapeException;
+import org.locationtech.spatial4j.shape.Point;
+import org.locationtech.spatial4j.shape.Rectangle;
+import org.locationtech.spatial4j.shape.impl.Range;
import java.util.Random;
@@ -230,14 +229,10 @@ public class RandomShapeGenerator extends RandomGeoGenerator {
// The validate flag will check for these possibilities and bail if an incorrect geometry is created
try {
pgb.build();
- } catch (Throwable e) {
+ } catch (AssertionError | InvalidShapeException e) {
// jts bug may occasionally misinterpret coordinate order causing an unhelpful ('geom' assertion)
// or InvalidShapeException
- if (e instanceof InvalidShapeException || e instanceof AssertionError) {
- return null;
- }
- // throw any other exception
- throw e;
+ return null;
}
}
return pgb;
diff --git a/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java b/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
index 28267e9beb..974929dddf 100644
--- a/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
+++ b/core/src/test/java/org/elasticsearch/threadpool/SimpleThreadPoolIT.java
@@ -19,8 +19,6 @@
package org.elasticsearch.threadpool;
-import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
-import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
@@ -36,7 +34,6 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.hamcrest.RegexMatcher;
-import org.elasticsearch.threadpool.ThreadPool.Names;
import org.elasticsearch.tribe.TribeIT;
import java.io.IOException;
@@ -46,19 +43,11 @@ import java.lang.management.ThreadMXBean;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.BrokenBarrierException;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.sameInstance;
/**
*/
@@ -136,9 +125,9 @@ public class SimpleThreadPoolIT extends ESIntegTestCase {
try {
new Node(settings);
fail("The node startup is supposed to fail");
- } catch(Throwable t) {
+ } catch(Exception e) {
//all good
- assertThat(t.getMessage(), containsString("mandatory plugins [non_existing]"));
+ assertThat(e.getMessage(), containsString("mandatory plugins [non_existing]"));
}
}
diff --git a/core/src/test/java/org/elasticsearch/update/UpdateIT.java b/core/src/test/java/org/elasticsearch/update/UpdateIT.java
index 55834c181b..c8cacbc36c 100644
--- a/core/src/test/java/org/elasticsearch/update/UpdateIT.java
+++ b/core/src/test/java/org/elasticsearch/update/UpdateIT.java
@@ -65,11 +65,8 @@ import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
-import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@@ -800,7 +797,7 @@ public class UpdateIT extends ESIntegTestCase {
final CountDownLatch latch = new CountDownLatch(numberOfThreads);
final CountDownLatch startLatch = new CountDownLatch(1);
final int numberOfUpdatesPerThread = scaledRandomIntBetween(100, 500);
- final List<Throwable> failures = new CopyOnWriteArrayList<>();
+ final List<Exception> failures = new CopyOnWriteArrayList<>();
for (int i = 0; i < numberOfThreads; i++) {
Runnable r = new Runnable() {
@@ -832,7 +829,7 @@ public class UpdateIT extends ESIntegTestCase {
logger.warn("Test was forcefully stopped. Client [{}] may still have outstanding requests.", Thread.currentThread().getName());
failures.add(e);
Thread.currentThread().interrupt();
- } catch (Throwable e) {
+ } catch (Exception e) {
failures.add(e);
} finally {
latch.countDown();
@@ -900,7 +897,7 @@ public class UpdateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
synchronized (failedMap) {
incrementMapValue(id, failedMap);
}
@@ -922,7 +919,7 @@ public class UpdateIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
synchronized (failedMap) {
incrementMapValue(id, failedMap);
}
@@ -976,7 +973,7 @@ public class UpdateIT extends ESIntegTestCase {
}
}
}
- } catch (Throwable e) {
+ } catch (Exception e) {
logger.error("Something went wrong", e);
failures.add(e);
} finally {
diff --git a/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java b/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java
index b2cc794ac6..e2c572f783 100644
--- a/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java
+++ b/core/src/test/java/org/elasticsearch/versioning/ConcurrentDocumentOperationIT.java
@@ -53,7 +53,7 @@ public class ConcurrentDocumentOperationIT extends ESIntegTestCase {
}
@Override
- public void onFailure(Throwable e) {
+ public void onFailure(Exception e) {
logger.error("Unexpected exception while indexing", e);
failure.set(e);
latch.countDown();