Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ping correctly in NioTransport #25462

Merged
merged 3 commits into from
Jun 29, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public int read() throws IOException {

try {
BytesReference messageWithoutHeader = message.slice(6, message.length() - 6);
handler.handleMessage(messageWithoutHeader, channel, channel.getProfile(), messageWithoutHeader.length());

// A message length of 6 bytes it is just a ping. Ignore for now.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, should we check if the header is correct and if not close the connection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens in the TcpFrameDecoder here. If the header is invalid, an exception is thrown .

When the exception is caught, the channel goes through out normal exception handling (and disconnect) logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good! just leave a comment about this in the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment next to the usage of frame decoder to indicate that it would thrown an exception if the message turned out to be invalid.

if (messageLengthWithHeader != 6) {
handler.handleMessage(messageWithoutHeader, channel, channel.getProfile(), messageWithoutHeader.length());
}
} catch (Exception e) {
handler.handleException(channel, e);
}
Expand Down