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.
This commit is contained in:
Jason Tedor 2016-11-30 15:26:32 -05:00
parent c90ba67abb
commit 761325bf94
1 changed files with 8 additions and 0 deletions

View File

@ -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()));
}
}