Repository: tinkerpop Updated Branches: refs/heads/tp33 84777d4a0 -> bf79a49a0
Make closing of connections robust TINKERPOP-2026 Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4965803a Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4965803a Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4965803a Branch: refs/heads/tp33 Commit: 4965803ae8e9283817e0171e1c463014c9166970 Parents: 3afc576 Author: Florian Hockmann <f...@florian-hockmann.de> Authored: Sat Sep 1 17:02:23 2018 +0200 Committer: Florian Hockmann <f...@florian-hockmann.de> Committed: Sat Sep 1 17:02:23 2018 +0200 ---------------------------------------------------------------------- .../Gremlin.Net/Driver/WebSocketConnection.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4965803a/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs index 9672606..b5a4cc8 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs @@ -43,11 +43,24 @@ namespace Gremlin.Net.Driver public async Task CloseAsync() { - await - _client.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None) - .ConfigureAwait(false); + if (CloseAlreadyInitiated) return; + + try + { + await + _client.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None) + .ConfigureAwait(false); + } + catch (Exception) + { + // Swallow exceptions silently as there is nothing to do when closing fails + } } + private bool CloseAlreadyInitiated => _client.State == WebSocketState.Closed || + _client.State == WebSocketState.Aborted || + _client.State == WebSocketState.CloseSent; + public async Task SendMessageAsync(byte[] message) { await