Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D3FEA20049D for ; Wed, 9 Aug 2017 11:48:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D2631161C1E; Wed, 9 Aug 2017 09:48:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F21AB161C27 for ; Wed, 9 Aug 2017 11:48:04 +0200 (CEST) Received: (qmail 19453 invoked by uid 500); 9 Aug 2017 09:48:04 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 19444 invoked by uid 99); 9 Aug 2017 09:48:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Aug 2017 09:48:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C5B15E00C5; Wed, 9 Aug 2017 09:48:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: jorgebg@apache.org To: commits@tinkerpop.apache.org Message-Id: <029237b49d5449c28f99539212d7c0ce@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: tinkerpop git commit: Unwrap AggregateException for sync io operations Date: Wed, 9 Aug 2017 09:48:02 +0000 (UTC) archived-at: Wed, 09 Aug 2017 09:48:06 -0000 Repository: tinkerpop Updated Branches: refs/heads/TINKERPOP-1744 [created] ea96bf4ae 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/ea96bf4a Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ea96bf4a Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ea96bf4a Branch: refs/heads/TINKERPOP-1744 Commit: ea96bf4aeb450ea87b7dda15995928d2d4acfbab Parents: 1e3c359 Author: Jorge Bay Gondra Authored: Wed Aug 9 11:46:28 2017 +0200 Committer: Jorge Bay Gondra Committed: Wed Aug 9 11:46:28 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/ea96bf4a/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/ea96bf4a/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(SideEffectCloseMessage()).Wait(); + _gremlinClient.SubmitAsync(SideEffectCloseMessage()).WaitUnwrap(); } private RequestMessage SideEffectCloseMessage() http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ea96bf4a/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 /// public void Apply(ITraversal traversal) { - ApplyAsync(traversal).Wait(); + ApplyAsync(traversal).WaitUnwrap(); } /// http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ea96bf4a/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 +{ + /// + /// Contains useful methods that can be reused across the project. + /// + internal static class Utils + { + /// + /// Waits the completion of the provided Task. + /// When an AggregateException is thrown, the inner exception is thrown. + /// + 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/ea96bf4a/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(() => testTraversal.Next()); + } [Fact] public async Task ShouldSendBytecodeToGremlinServerAsynchronouslyForTraversalPromise()