Better error hanndling during client & server start, and during handshakes #4790
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.
Identify the Bug or Feature request
Improves on #4787
Description of the Change
I hope this will be the last in this series of PRs. This change fixes some edge cases during server start and client connect that can still leave the app in a bad state.
For server starts, some extra care is taken in the order of operations. We now always create the server first (if any) and then create the local client. And we always start the server first then start the local client. If the server fails to start with an
IOException
, we can just propagate the exception since the caller handles that case. If the client fails to start, we make a point of stopping the already-started server before propagating the exception.The previous point also required some internal changes to servers and clients. Any
IOException
thrown in theirstart()
methods will result in their states being set toStopped
andClosed
respectively. This avoids the possibility that such a client or server is mistakenly identified as still running.On the handshake side, the completion callbacks now receive a flag indicating whether the handshake was a success. Some of these callbacks have behaviour that should only trigger in success cases, while others have logic for both cases. An important case is that glass panes are hidden regardless of outcome, but a new glass pane is only installed if proceeding to the next step.
MapToolClient
now treats handshake failures as an unexpected disconnection.Possible Drawbacks
Should be none.
Documentation Notes
N/A
Release Notes
This change is