From 6e4defd3c511583aeeccc3deafff138d682ef9cf Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Mon, 8 Apr 2019 14:47:58 +0200 Subject: [PATCH] Relax Overly Strict Assertion in TransportShardBulkAction (#40940) * Remove Overly Strict Assertion in TransportShardBulkAction * In #39793 this assertion was added under the assumption that no exceptions would be thrown in this method, which turned out not to be correct and at the very least `org.elasticsearch.index.shard.IndexShardClosedException` can be thrown by `org.elasticsearch.index.shard.IndexShard.sync` * Closes #40933 --- .../action/bulk/TransportShardBulkAction.java | 10 +++++----- .../xpack/ml/integration/AnnotationIndexIT.java | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index a55de9f1497b2..1117971e53517 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -147,7 +147,7 @@ public static void performOnPrimary( Consumer> waitForMappingUpdate, ActionListener> listener, ThreadPool threadPool) { - new ActionRunnable>(listener) { + new ActionRunnable<>(listener) { private final Executor executor = threadPool.executor(ThreadPool.Names.WRITE); @@ -189,11 +189,11 @@ public void onRejection(Exception e) { } private void finishRequest() { - listener.onResponse( - new WritePrimaryResult<>(context.getBulkShardRequest(), context.buildShardResponse(), context.getLocationToSync(), - null, context.getPrimary(), logger)); + ActionListener.completeWith(listener, + () -> new WritePrimaryResult<>( + context.getBulkShardRequest(), context.buildShardResponse(), context.getLocationToSync(), null, + context.getPrimary(), logger)); } - }.run(); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java index b66ef8e0e82b5..b19266956cb8d 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java @@ -51,7 +51,6 @@ public void testNotCreatedWhenNoOtherMlIndices() { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/40933") public void testCreatedWhenAfterOtherMlIndex() throws Exception { Auditor auditor = new Auditor(client(), "node_1");