From ee193f769799c303c3edb377a96c64b98fc19b19 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 11 Jul 2016 16:36:26 +0200 Subject: [PATCH] [TEST] Catch RejectedOperationException when disconnecting from node in MockTcpTransport --- .../org/elasticsearch/transport/MockTcpTransport.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java b/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java index 396b826fc4e..1adce471c5d 100644 --- a/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java +++ b/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java @@ -54,6 +54,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; @@ -174,9 +175,13 @@ public class MockTcpTransport extends TcpTransport Consumer onClose = (channel) -> { final NodeChannels connected = connectedNodes.get(node); if (connected != null && connected.hasChannel(channel)) { - executor.execute(() -> { - disconnectFromNode(node, channel, "channel closed event"); - }); + try { + executor.execute(() -> { + disconnectFromNode(node, channel, "channel closed event"); + }); + } catch (RejectedExecutionException ex) { + logger.debug("failed to run disconnectFromNode - node is shutting down"); + } } }; InetSocketAddress address = ((InetSocketTransportAddress) node.getAddress()).address();