From fb1f7eb9ec1b473bbaa319c11f42bc827ec27848 Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 15 Apr 2019 16:36:51 +0100 Subject: [PATCH] fail in try block --- .../replication/TransportReplicationActionTests.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java index b468bbba7ca71..1cb36d196b576 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java @@ -836,20 +836,18 @@ protected void shardOperationOnPrimary(Request shardRequest, IndexShard primary, try { listener.get(); + if (throwExceptionOnRun || respondWithError) { + fail("expected exception, but none was thrown"); + } } catch (ExecutionException e) { if (throwExceptionOnRun || respondWithError) { Throwable cause = e.getCause(); assertThat(cause, instanceOf(ElasticsearchException.class)); assertThat(cause.getMessage(), containsString("simulated")); - return; } else { throw e; } } - - if (throwExceptionOnRun || respondWithError) { - fail("expected exception, but none was thrown"); - } } public void testReplicasCounter() {