From 4b5935a7084407aa536a5785950aae8ad2a1f1dd Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Sat, 21 Sep 2013 23:10:30 +0200 Subject: [PATCH] Small cleanups in TransportClient et.al Catching Throwable instead of Exception in TransportClient and TransportClientNodesService and restore interrupted flag if interrupt exception is caught and ignored --- .../org/elasticsearch/client/transport/TransportClient.java | 1 + .../client/transport/TransportClientNodesService.java | 4 ++-- .../elasticsearch/cluster/service/InternalClusterService.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/src/main/java/org/elasticsearch/client/transport/TransportClient.java index fab81334870..8def84d8276 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -272,6 +272,7 @@ public class TransportClient extends AbstractClient { injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) { // ignore + Thread.currentThread().interrupt(); } try { injector.getInstance(ThreadPool.class).shutdownNow(); diff --git a/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 837085c2812..ac3fc064127 100644 --- a/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -303,7 +303,7 @@ public class TransportClientNodesService extends AbstractComponent { if (!transportService.nodeConnected(node)) { try { transportService.connectToNode(node); - } catch (Exception e) { + } catch (Throwable e) { logger.debug("failed to connect to node [{}], removed from nodes list", e, node); continue; } @@ -435,7 +435,7 @@ public class TransportClientNodesService extends AbstractComponent { try { logger.trace("connecting to node [{}]", node); transportService.connectToNode(node); - } catch (Exception e) { + } catch (Throwable e) { it.remove(); logger.debug("failed to connect to discovered node [" + node + "]", e); } diff --git a/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java b/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java index caed77f86e8..3e9f769a0de 100644 --- a/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java +++ b/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java @@ -22,6 +22,7 @@ package org.elasticsearch.cluster.service; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.cluster.*; +import org.elasticsearch.cluster.ClusterState.Builder; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.MetaData; @@ -49,7 +50,6 @@ import java.util.List; import java.util.Queue; import java.util.concurrent.*; -import static org.elasticsearch.cluster.ClusterState.Builder; import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder; import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; @@ -370,7 +370,7 @@ public class InternalClusterService extends AbstractLifecycleComponent