Handle ping correctly in NioTransport (#25462)

Our current TCPTransport logic assumes that we do not pass pings to
the TCPTransport level.

This commit fixes an issue where NioTransport was passing pings to
TCPTransport and leading to exceptions.
This commit is contained in:
Tim Brooks 2017-06-29 11:03:51 -05:00 committed by GitHub
parent acade2b40a
commit 6c58f0c4e6
1 changed files with 7 additions and 1 deletions

View File

@ -67,6 +67,8 @@ public class TcpReadContext implements ReadContext {
BytesReference message;
// Frame decoder will throw an exception if the message is improperly formatted, the header is incorrect,
// or the message is corrupted
while ((message = frameDecoder.decode(createCompositeBuffer(), rawBytesCount)) != null) {
int messageLengthWithHeader = message.length();
NetworkBytesReference.vectorizedIncrementReadIndexes(references, messageLengthWithHeader);
@ -75,7 +77,11 @@ public class TcpReadContext implements ReadContext {
try {
BytesReference messageWithoutHeader = message.slice(6, message.length() - 6);
// A message length of 6 bytes it is just a ping. Ignore for now.
if (messageLengthWithHeader != 6) {
handler.handleMessage(messageWithoutHeader, channel, channel.getProfile(), messageWithoutHeader.length());
}
} catch (Exception e) {
handler.handleException(channel, e);
}