From 7898522514c1ea532da7d7d0760c586f39c482c5 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Fri, 18 Mar 2016 09:51:00 +0100 Subject: [PATCH] Provide better error message when an incompatible node connects to a node We should give a better exception message when an incompatible node connects and we receive a messeage. This commit adds a clear excpetion based on the protocol version received instead of throwing cryptic messages about not fully reaed buffer etc. Relates to #17090 --- .../elasticsearch/transport/netty/MessageChannelHandler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java b/core/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java index 302f8296ad3..9eef4401144 100644 --- a/core/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java +++ b/core/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java @@ -127,6 +127,10 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { } streamIn = compressor.streamInput(streamIn); } + if (version.onOrAfter(Version.CURRENT.minimumCompatibilityVersion()) == false || version.major != Version.CURRENT.major) { + throw new IllegalStateException("Received message from unsupported version: [" + version + + "] minimal compatible version is: [" +Version.CURRENT.minimumCompatibilityVersion() + "]"); + } streamIn.setVersion(version); if (TransportStatus.isRequest(status)) { threadContext.readHeaders(streamIn);