Fix issue #1418: WebSocketServer sometimes misses GET request after SSL handshake #1419
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
On Ubuntu 22.04 with Linux 6.5, it was observed that when the server gets the SSL records containing the client handshake finished message and the first HTTP GET request in ONE read operation, the latter SSL record is never processed.
Commit 89eaf41 should have fixed this, but it turned out that when SSLSocketChannel2#processHandshake() is called from SSLSocketChannel2#write(), the second SSL record containing the HTTP GET request is stashed away, but never retrieved, since the calling code in WebSocketServer#doWrite() has no provisions for this, only WebSocketServer#doRead() does.
Change SSLSocketChannel2#processHandshake() to only read from the socket when called from SSLSocketChannel#read(), to ensure that when two SSL records are read, the second one is processed as well.
Related Issue
Fixes #1418
Motivation and Context
Our integration tests which locally connect a WebSocketClient to a WebSocketServer were sporadically failing when run on Ubuntu 22.04 with Linux 6.5 (this never occurred in Ubuntu 20.04 with Linux 5.14).
With this change, the tests run reliably. We have verified from detailed java.net debug logs that when two SSL records are retrieved in one read, they are now both processed.
How Has This Been Tested?
Tested with our internal integration tests.
Types of changes
Checklist: