If a client sends a close-notify alert prior to closing the connection, the NIO HttpsServerHelper goes into an infinite loop in the ready loop in Connection.onSelected. This happens on both Android and JSE. The Android client appears to send a close-notify in some scenarios, and curl (on MacOSX) does it every time.
What appears to be happening is the following:
- When the close-notify is received by the server, its SSLEngine returns status=CLOSED handshake_status=NEED_WRAP. (The NEED_WRAP is because it wants to send its own close-notify back to the client.)
- In the post-processing of the network queue (ReadableSslChannel.postProcess), SslConnection.handleSslResult is called, which marks the connection Closing and clears the SSL result
- In the post-processing of the application queue (HttpsServerInboundWay.postProcess), SslConnection.handleSslResult is called again. This time, it assumes a status of OK (because the result had been cleared), and calls handleSslHandshake().
- handleSslHandshake() sees the NEED_WRAP handshake status and sets the outbound way's IO State to READY
- The SSLEngine produces its own close-notify message, then immediately begins returning NOT_HANDSHAKING. It never returns FINISHED, so the state of the outbound way is never changed from READY, and the ready loop continues forever.
If a client sends a close-notify alert prior to closing the connection, the NIO HttpsServerHelper goes into an infinite loop in the ready loop in Connection.onSelected. This happens on both Android and JSE. The Android client appears to send a close-notify in some scenarios, and curl (on MacOSX) does it every time.
What appears to be happening is the following: