From 785624e96b03c5fc011bfd89429036d758b404b7 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 4 Aug 2016 11:22:13 -0400 Subject: [PATCH] Restore interrupted status on when closing client When closing a transport client that depends on Netty 4, interrupted exceptions can be thrown while shutting down some Netty threads. This commit refactors the handling of these exceptions to finish shutting down and then just restore the interrupted status. --- .../transport/client/PreBuiltTransportClient.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/transport/src/main/java/org/elasticsearch/transport/client/PreBuiltTransportClient.java b/client/transport/src/main/java/org/elasticsearch/transport/client/PreBuiltTransportClient.java index acc28f2e34a..cc7e722d802 100644 --- a/client/transport/src/main/java/org/elasticsearch/transport/client/PreBuiltTransportClient.java +++ b/client/transport/src/main/java/org/elasticsearch/transport/client/PreBuiltTransportClient.java @@ -21,6 +21,7 @@ package org.elasticsearch.transport.client; import io.netty.util.ThreadDeathWatcher; import io.netty.util.concurrent.GlobalEventExecutor; +import org.apache.lucene.util.IOUtils; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Setting; @@ -95,9 +96,13 @@ public class PreBuiltTransportClient extends TransportClient { || NetworkModule.TRANSPORT_TYPE_SETTING.get(settings).equals(Netty4Plugin.NETTY_TRANSPORT_NAME)) { try { GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + try { ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { - throw new RuntimeException(e); + Thread.currentThread().interrupt(); } } }