You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2017/09/14 15:48:38 UTC
[1/7] tinkerpop git commit: Add handling for closed connections
Repository: tinkerpop
Updated Branches:
refs/heads/master e8230c68f -> dd09c0595
Add handling for closed connections
Closed connections are not returned to the ConnectionPool as the client cannot send any further requests with them. Additionally, the host is considered to be unavailable when a connection was closed and all other connections are closed and removed from the ConnectionPool. This is in line with the handling for closed connection in gremlin-driver.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/98e4e1b8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/98e4e1b8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/98e4e1b8
Branch: refs/heads/master
Commit: 98e4e1b8201f50e1f34458a82c20f2737aa6ae53
Parents: 397158a
Author: florianhockmann <fl...@apache.org>
Authored: Sat Sep 2 17:54:39 2017 +0200
Committer: florianhockmann <fl...@apache.org>
Committed: Sat Sep 2 17:54:39 2017 +0200
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/Connection.cs | 2 +
.../src/Gremlin.Net/Driver/ConnectionPool.cs | 62 ++++++++++++++------
.../Gremlin.Net/Driver/WebSocketConnection.cs | 2 +
3 files changed, 47 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98e4e1b8/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
index 126b461..dbbd375 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
@@ -68,6 +68,8 @@ namespace Gremlin.Net.Driver
await _webSocketConnection.CloseAsync().ConfigureAwait(false);
}
+ public bool IsOpen => _webSocketConnection.IsOpen;
+
private async Task SendAsync(RequestMessage message)
{
var graphsonMsg = _graphSONWriter.WriteObject(message);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98e4e1b8/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
index 945e5e4..779815a 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
@@ -55,7 +55,7 @@ namespace Gremlin.Net.Driver
if (connection == null)
connection = await CreateNewConnectionAsync().ConfigureAwait(false);
- return new ProxyConnection(connection, AddConnection);
+ return new ProxyConnection(connection, AddConnectionIfOpen);
}
private async Task<Connection> CreateNewConnectionAsync()
@@ -66,6 +66,17 @@ namespace Gremlin.Net.Driver
return newConnection;
}
+ private void AddConnectionIfOpen(Connection connection)
+ {
+ if (!connection.IsOpen)
+ {
+ ConsiderUnavailable();
+ connection.Dispose();
+ return;
+ }
+ AddConnection(connection);
+ }
+
private void AddConnection(Connection connection)
{
lock (_connectionsLock)
@@ -74,6 +85,36 @@ namespace Gremlin.Net.Driver
}
}
+ private void ConsiderUnavailable()
+ {
+ CloseAndRemoveAllConnections();
+ }
+
+ private void CloseAndRemoveAllConnections()
+ {
+ lock (_connectionsLock)
+ {
+ TeardownAsync().WaitUnwrap();
+ RemoveAllConnections();
+ }
+ }
+
+ private void RemoveAllConnections()
+ {
+ while (!_connections.IsEmpty)
+ {
+ _connections.TryTake(out var connection);
+ connection.Dispose();
+ }
+ }
+
+ private async Task TeardownAsync()
+ {
+ var closeTasks = new List<Task>(_connections.Count);
+ closeTasks.AddRange(_connections.Select(conn => conn.CloseAsync()));
+ await Task.WhenAll(closeTasks).ConfigureAwait(false);
+ }
+
#region IDisposable Support
private bool _disposed;
@@ -89,27 +130,10 @@ namespace Gremlin.Net.Driver
if (!_disposed)
{
if (disposing)
- lock (_connectionsLock)
- {
- if (_connections != null && !_connections.IsEmpty)
- {
- TeardownAsync().WaitUnwrap();
-
- foreach (var conn in _connections)
- conn.Dispose();
- }
- }
+ CloseAndRemoveAllConnections();
_disposed = true;
}
}
-
- private async Task TeardownAsync()
- {
- var closeTasks = new List<Task>(_connections.Count);
- closeTasks.AddRange(_connections.Select(conn => conn.CloseAsync()));
- await Task.WhenAll(closeTasks).ConfigureAwait(false);
- }
-
#endregion
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/98e4e1b8/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 5a20759..9672606 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/WebSocketConnection.cs
@@ -71,6 +71,8 @@ namespace Gremlin.Net.Driver
}
}
+ public bool IsOpen => _client.State == WebSocketState.Open;
+
#region IDisposable Support
private bool _disposed;
[6/7] tinkerpop git commit: Move Utils to Gremlin.Net.Process
Posted by fl...@apache.org.
Move Utils to Gremlin.Net.Process
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/bc81a5be
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/bc81a5be
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/bc81a5be
Branch: refs/heads/master
Commit: bc81a5be7a6c6fddbd2e6111770d9b99308153ae
Parents: 755da22
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Aug 9 15:28:21 2017 +0200
Committer: florianhockmann <fh...@florian-hockmann.de>
Committed: Thu Sep 14 17:04:10 2017 +0200
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/ConnectionPool.cs | 2 +-
.../Remote/DriverRemoteTraversalSideEffects.cs | 2 +-
.../Process/Remote/RemoteStrategy.cs | 1 -
gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs | 55 ++++++++++++++++++++
.../src/Gremlin.Net/Structure/Utils.cs | 55 --------------------
5 files changed, 57 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc81a5be/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
index 98cb547..945e5e4 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
@@ -26,7 +26,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Gremlin.Net.Structure;
+using Gremlin.Net.Process;
namespace Gremlin.Net.Driver
{
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc81a5be/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
index e8df942..8f2b3e6 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
@@ -25,8 +25,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Gremlin.Net.Driver.Messages;
+using Gremlin.Net.Process;
using Gremlin.Net.Process.Traversal;
-using Gremlin.Net.Structure;
namespace Gremlin.Net.Driver.Remote
{
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc81a5be/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
index b914063..098a46d 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
@@ -23,7 +23,6 @@
using System.Threading.Tasks;
using Gremlin.Net.Process.Traversal;
-using Gremlin.Net.Structure;
namespace Gremlin.Net.Process.Remote
{
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc81a5be/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs
new file mode 100644
index 0000000..e1781ab
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Utils.cs
@@ -0,0 +1,55 @@
+#region License
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#endregion
+
+using System;
+using System.Runtime.ExceptionServices;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Process
+{
+ /// <summary>
+ /// Contains useful methods that can be reused across the project.
+ /// </summary>
+ internal static class Utils
+ {
+ /// <summary>
+ /// Waits the completion of the provided Task.
+ /// When an AggregateException is thrown, the inner exception is thrown.
+ /// </summary>
+ public static void WaitUnwrap(this Task task)
+ {
+ try
+ {
+ task.Wait();
+ }
+ catch (AggregateException ex)
+ {
+ if (ex.InnerExceptions.Count == 1)
+ {
+ ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
+ }
+ throw;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bc81a5be/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs
deleted file mode 100644
index 08168ba..0000000
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-#region License
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#endregion
-
-using System;
-using System.Runtime.ExceptionServices;
-using System.Threading.Tasks;
-
-namespace Gremlin.Net.Structure
-{
- /// <summary>
- /// Contains useful methods that can be reused across the project.
- /// </summary>
- internal static class Utils
- {
- /// <summary>
- /// Waits the completion of the provided Task.
- /// When an AggregateException is thrown, the inner exception is thrown.
- /// </summary>
- public static void WaitUnwrap(this Task task)
- {
- try
- {
- task.Wait();
- }
- catch (AggregateException ex)
- {
- if (ex.InnerExceptions.Count == 1)
- {
- ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
- }
- throw;
- }
- }
- }
-}
\ No newline at end of file
[7/7] tinkerpop git commit: Merge branch 'tp32'
Posted by fl...@apache.org.
Merge branch 'tp32'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/dd09c059
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/dd09c059
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/dd09c059
Branch: refs/heads/master
Commit: dd09c059566a0e4d48845ac1dcc789ae075ff10b
Parents: bc81a5b 9402e4e
Author: florianhockmann <fh...@florian-hockmann.de>
Authored: Thu Sep 14 17:05:52 2017 +0200
Committer: florianhockmann <fh...@florian-hockmann.de>
Committed: Thu Sep 14 17:05:52 2017 +0200
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/Connection.cs | 2 +
.../src/Gremlin.Net/Driver/ConnectionPool.cs | 59 +++++++++++++-------
.../Gremlin.Net/Driver/WebSocketConnection.cs | 2 +
.../Gremlin.Net.IntegrationTest.csproj | 2 +-
.../Gremlin.Net.UnitTest.csproj | 4 +-
5 files changed, 47 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dd09c059/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
----------------------------------------------------------------------
[3/7] tinkerpop git commit: Improve closing and removing of
connections in ConnectionPool
Posted by fl...@apache.org.
Improve closing and removing of connections in ConnectionPool
This resolves a possible race condition.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ef658752
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ef658752
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ef658752
Branch: refs/heads/master
Commit: ef658752099e127fa1f4e3e6737a0b6f81270622
Parents: d9a4f79
Author: florianhockmann <fl...@apache.org>
Authored: Wed Sep 6 20:53:11 2017 +0200
Committer: florianhockmann <fl...@apache.org>
Committed: Wed Sep 6 20:53:11 2017 +0200
----------------------------------------------------------------------
gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ef658752/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
index 779815a..9501686 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
@@ -101,18 +101,15 @@ namespace Gremlin.Net.Driver
private void RemoveAllConnections()
{
- while (!_connections.IsEmpty)
+ while (_connections.TryTake(out var connection))
{
- _connections.TryTake(out var connection);
connection.Dispose();
}
}
private async Task TeardownAsync()
{
- var closeTasks = new List<Task>(_connections.Count);
- closeTasks.AddRange(_connections.Select(conn => conn.CloseAsync()));
- await Task.WhenAll(closeTasks).ConfigureAwait(false);
+ await Task.WhenAll(_connections.Select(c => c.CloseAsync())).ConfigureAwait(false);
}
#region IDisposable Support
[4/7] tinkerpop git commit: Merge branch 'TINKERPOP-1766' into tp32
Posted by fl...@apache.org.
Merge branch 'TINKERPOP-1766' into tp32
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9402e4e4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9402e4e4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9402e4e4
Branch: refs/heads/master
Commit: 9402e4e4384d7062f87f143a6ffbfddaa13781df
Parents: 736cb26 ef65875
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Thu Sep 14 12:35:59 2017 +0200
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Thu Sep 14 12:35:59 2017 +0200
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/Connection.cs | 2 +
.../src/Gremlin.Net/Driver/ConnectionPool.cs | 59 +++++++++++++-------
.../Gremlin.Net/Driver/WebSocketConnection.cs | 2 +
.../Gremlin.Net.IntegrationTest.csproj | 2 +-
.../Gremlin.Net.UnitTest.csproj | 4 +-
5 files changed, 47 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
[2/7] tinkerpop git commit: Update NuGet packages of test projects
Posted by fl...@apache.org.
Update NuGet packages of test projects
One of the dependencies (Castle.Core) produced a warning because one of its dependencies couldn't be found in the specified version. This doesn't occur anymore for the updated version.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/d9a4f79f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/d9a4f79f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/d9a4f79f
Branch: refs/heads/master
Commit: d9a4f79f7c568761461dc11d22fbf907578f7d14
Parents: 98e4e1b
Author: florianhockmann <fl...@apache.org>
Authored: Sat Sep 2 18:00:52 2017 +0200
Committer: florianhockmann <fl...@apache.org>
Committed: Sat Sep 2 18:00:52 2017 +0200
----------------------------------------------------------------------
.../Gremlin.Net.IntegrationTest.csproj | 2 +-
.../test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d9a4f79f/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
index fed1c49..9d00a5a 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj
@@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.1" />
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d9a4f79f/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
index db36085..41617be 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
@@ -13,8 +13,8 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
- <PackageReference Include="Moq" Version="4.7.1" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
+ <PackageReference Include="Moq" Version="4.7.99" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="OpenCover" Version="4.6.519" />
[5/7] tinkerpop git commit: Unwrap AggregateException for sync io
operations
Posted by fl...@apache.org.
Unwrap AggregateException for sync io operations
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/755da22f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/755da22f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/755da22f
Branch: refs/heads/master
Commit: 755da22ff08762bb28c04fb3d84b19dbf492c2cd
Parents: e8230c6
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Wed Aug 9 11:46:28 2017 +0200
Committer: florianhockmann <fh...@florian-hockmann.de>
Committed: Thu Sep 14 17:03:15 2017 +0200
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/ConnectionPool.cs | 3 +-
.../Remote/DriverRemoteTraversalSideEffects.cs | 3 +-
.../Process/Remote/RemoteStrategy.cs | 3 +-
.../src/Gremlin.Net/Structure/Utils.cs | 55 ++++++++++++++++++++
.../Process/Remote/RemoteStrategyTests.cs | 12 +++++
5 files changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/755da22f/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
index e9ce9a8..98cb547 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs
@@ -26,6 +26,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Gremlin.Net.Structure;
namespace Gremlin.Net.Driver
{
@@ -92,7 +93,7 @@ namespace Gremlin.Net.Driver
{
if (_connections != null && !_connections.IsEmpty)
{
- TeardownAsync().Wait();
+ TeardownAsync().WaitUnwrap();
foreach (var conn in _connections)
conn.Dispose();
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/755da22f/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
index 8ce495d..e8df942 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Remote/DriverRemoteTraversalSideEffects.cs
@@ -26,6 +26,7 @@ using System.Collections.Generic;
using System.Linq;
using Gremlin.Net.Driver.Messages;
using Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Structure;
namespace Gremlin.Net.Driver.Remote
{
@@ -112,7 +113,7 @@ namespace Gremlin.Net.Driver.Remote
private void CloseSideEffects()
{
- _gremlinClient.SubmitAsync<object>(SideEffectCloseMessage()).Wait();
+ _gremlinClient.SubmitAsync<object>(SideEffectCloseMessage()).WaitUnwrap();
}
private RequestMessage SideEffectCloseMessage()
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/755da22f/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
index b3f8c44..b914063 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs
@@ -23,6 +23,7 @@
using System.Threading.Tasks;
using Gremlin.Net.Process.Traversal;
+using Gremlin.Net.Structure;
namespace Gremlin.Net.Process.Remote
{
@@ -46,7 +47,7 @@ namespace Gremlin.Net.Process.Remote
/// <inheritdoc />
public void Apply<S, E>(ITraversal<S, E> traversal)
{
- ApplyAsync(traversal).Wait();
+ ApplyAsync(traversal).WaitUnwrap();
}
/// <inheritdoc />
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/755da22f/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs
new file mode 100644
index 0000000..08168ba
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/Utils.cs
@@ -0,0 +1,55 @@
+#region License
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#endregion
+
+using System;
+using System.Runtime.ExceptionServices;
+using System.Threading.Tasks;
+
+namespace Gremlin.Net.Structure
+{
+ /// <summary>
+ /// Contains useful methods that can be reused across the project.
+ /// </summary>
+ internal static class Utils
+ {
+ /// <summary>
+ /// Waits the completion of the provided Task.
+ /// When an AggregateException is thrown, the inner exception is thrown.
+ /// </summary>
+ public static void WaitUnwrap(this Task task)
+ {
+ try
+ {
+ task.Wait();
+ }
+ catch (AggregateException ex)
+ {
+ if (ex.InnerExceptions.Count == 1)
+ {
+ ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
+ }
+ throw;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/755da22f/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
index 7b99371..5c24346 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Remote/RemoteStrategyTests.cs
@@ -24,6 +24,7 @@
using System;
using System.Threading.Tasks;
using Gremlin.Net.Driver;
+using Gremlin.Net.Driver.Exceptions;
using Gremlin.Net.Driver.Remote;
using Gremlin.Net.Process.Remote;
using Gremlin.Net.Process.Traversal;
@@ -50,6 +51,17 @@ namespace Gremlin.Net.IntegrationTest.Process.Remote
Assert.Equal(expectedResult, actualResult);
}
+
+ [Fact]
+ public void ShouldThrowOriginalExceptionWhenByteCodeIsInvalid()
+ {
+ var testBytecode = new Bytecode();
+ testBytecode.AddStep("V");
+ testBytecode.AddStep("this_step_does_not_exist", "test");
+ var testTraversal = CreateTraversalWithRemoteStrategy(testBytecode);
+
+ Assert.Throws<ResponseException>(() => testTraversal.Next());
+ }
[Fact]
public async Task ShouldSendBytecodeToGremlinServerAsynchronouslyForTraversalPromise()