tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [1/4] tinkerpop git commit: Make closing of connections robust TINKERPOP-2026 [Forced Update!]
Date Sat, 22 Sep 2018 01:39:34 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-2030 564236ed6 -> 207c660a1 (forced update)


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/TINKERPOP-2030
Commit: 4965803ae8e9283817e0171e1c463014c9166970
Parents: 3afc576
Author: Florian Hockmann <fh@florian-hockmann.de>
Authored: Sat Sep 1 17:02:23 2018 +0200
Committer: Florian Hockmann <fh@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


Mime
View raw message