diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportService.java index db0d433a2ad..9c489728685 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportService.java @@ -21,6 +21,8 @@ package org.elasticsearch.transport; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.collect.ImmutableMap; +import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.Streamable; @@ -34,13 +36,11 @@ import org.elasticsearch.threadpool.ThreadPool; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicLong; import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*; -import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.*; /** * @author kimchy (shay.banon) @@ -51,7 +51,8 @@ public class TransportService extends AbstractLifecycleComponent serverHandlers = newConcurrentMap(); + volatile ImmutableMap serverHandlers = ImmutableMap.of(); + final Object serverHandlersMutex = new Object(); final ConcurrentMapLong clientHandlers = ConcurrentCollections.newConcurrentMapLong(); @@ -212,14 +213,19 @@ public class TransportService extends AbstractLifecycleComponent