From 761325bf9498db566d4d98193e12b7630dda7a80 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 30 Nov 2016 15:26:32 -0500 Subject: [PATCH] Throw exception on ping from another cluster When we receive a ping from another cluster, we should throw an exception so as to not leak the channel. --- .../org/elasticsearch/discovery/zen/UnicastZenPing.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java index e2d9fca6f69..bb5ecf6b123 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java @@ -64,6 +64,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Queue; @@ -597,6 +598,13 @@ public class UnicastZenPing extends AbstractComponent implements ZenPing { public void messageReceived(UnicastPingRequest request, TransportChannel channel) throws Exception { if (request.pingResponse.clusterName().equals(clusterName)) { channel.sendResponse(handlePingRequest(request)); + } else { + throw new IllegalStateException( + String.format( + Locale.ROOT, + "mismatched cluster names; request: [%s], local: [%s]", + request.pingResponse.clusterName().value(), + clusterName.value())); } }