You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/05/31 07:35:40 UTC

[09/19] ignite git commit: .NET: Fix compute exception propagation: throw AggregateException unchanged

.NET: Fix compute exception propagation: throw AggregateException unchanged


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/618a448a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/618a448a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/618a448a

Branch: refs/heads/ignite-5075
Commit: 618a448ab5fa2075a212b6a2abe4719a010038c3
Parents: 03b383c
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon May 29 23:37:47 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon May 29 23:37:47 2017 +0300

----------------------------------------------------------------------
 .../Compute/BinarizableClosureTaskTest.cs               |  7 ++-----
 .../Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs |  6 ++++--
 .../Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs  | 10 ++++------
 .../Compute/IgniteExceptionTaskSelfTest.cs              |  8 ++++++--
 .../Compute/SerializableClosureTaskTest.cs              |  5 +----
 .../Deployment/PeerAssemblyLoadingTest.cs               |  5 +++--
 .../Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs    |  5 +++--
 .../Impl/Binary/BinaryReflectiveActions.cs              |  7 +++++--
 .../dotnet/Apache.Ignite.Core/Impl/Common/Future.cs     | 12 ++----------
 9 files changed, 30 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
index e8952bf..3482456 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Tests.Compute
 {
     using System;
     using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
     using NUnit.Framework;
 
@@ -67,11 +68,7 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             Assert.IsTrue(err != null);
 
-            var aggregate = err as AggregateException;
-
-            if (aggregate != null)
-                err = aggregate.InnerException;
-
+            err = err.InnerException;
             Assert.IsNotNull(err);
 
             var err0 = err.InnerException as BinarizableException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
index ffb2844..a3b87ca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
@@ -213,9 +213,11 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             var args = Enumerable.Repeat(1, MultiCloCnt).Cast<object>().ToArray();
 
-            var e = Assert.Throws<Exception>(() => Grid1.GetCompute().Apply(Func(false), args, new Reducer(true)));
+            var e = Assert.Throws<AggregateException>(() =>
+                Grid1.GetCompute().Apply(Func(false), args, new Reducer(true)));
 
-            Assert.AreEqual(ErrMsg, e.Message);
+            Assert.IsNotNull(e.InnerException);
+            Assert.AreEqual(ErrMsg, e.InnerException.Message);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index e4fd853..0c6d20e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -1285,17 +1285,16 @@ namespace Apache.Ignite.Core.Tests.Compute
         [Test]
         public void TestExceptions()
         {
-            Assert.Throws<IgniteException>(() => _grid1.GetCompute().Broadcast(new InvalidComputeAction()));
+            Assert.Throws<AggregateException>(() => _grid1.GetCompute().Broadcast(new InvalidComputeAction()));
 
-            Assert.Throws<IgniteException>(
+            Assert.Throws<AggregateException>(
                 () => _grid1.GetCompute().Execute<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
                     typeof (NetSimpleTask), new NetSimpleJobArgument(-1)));
 
             // Local.
-            var ex = Assert.Throws<IgniteException>(() =>
+            var ex = Assert.Throws<AggregateException>(() =>
                 _grid1.GetCluster().ForLocal().GetCompute().Broadcast(new ExceptionalComputeAction()));
 
-            Assert.AreEqual("Async operation has failed, examine InnerException for details.", ex.Message);
             Assert.IsNotNull(ex.InnerException);
             Assert.AreEqual("Compute job has failed on local node, examine InnerException for details.", 
                 ex.InnerException.Message);
@@ -1303,10 +1302,9 @@ namespace Apache.Ignite.Core.Tests.Compute
             Assert.AreEqual(ExceptionalComputeAction.ErrorText, ex.InnerException.InnerException.Message);
 
             // Remote.
-            ex = Assert.Throws<IgniteException>(() =>
+            ex = Assert.Throws<AggregateException>(() =>
                 _grid1.GetCluster().ForRemotes().GetCompute().Broadcast(new ExceptionalComputeAction()));
 
-            Assert.AreEqual("Async operation has failed, examine InnerException for details.", ex.Message);
             Assert.IsNotNull(ex.InnerException);
             Assert.AreEqual("Compute job has failed on remote node, examine InnerException for details.",
                 ex.InnerException.Message);

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
index 2f9f6b4..9f157f4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
@@ -168,7 +168,8 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             _mode = ErrorMode.RmtJobErrNotMarshalable;
 
-            Assert.Throws<SerializationException>(() => Execute());
+            var ex = Assert.Throws<AggregateException>(() => Execute());
+            Assert.IsInstanceOf<SerializationException>(ex.InnerException);
         }
 
         /// <summary>
@@ -322,7 +323,10 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             JobErrs.Clear();
 
-            return Assert.Catch(() => Grid1.GetCompute().Execute(new Task()));
+            var ex = Assert.Throws<AggregateException>(() => Grid1.GetCompute().Execute(new Task()));
+
+            Assert.IsNotNull(ex.InnerException);
+            return ex.InnerException;
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
index ecb4aa5..48d544f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
@@ -67,10 +67,7 @@ namespace Apache.Ignite.Core.Tests.Compute
         {
             Assert.IsTrue(err != null);
 
-            var aggregate = err as AggregateException;
-
-            if (aggregate != null)
-                err = aggregate.InnerException;
+            err = err.InnerException;
 
             Assert.IsNotNull(err);
             SerializableException err0 = err.InnerException as SerializableException;

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Deployment/PeerAssemblyLoadingTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Deployment/PeerAssemblyLoadingTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Deployment/PeerAssemblyLoadingTest.cs
index c74375d..de1ecd6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Deployment/PeerAssemblyLoadingTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Deployment/PeerAssemblyLoadingTest.cs
@@ -22,7 +22,6 @@ namespace Apache.Ignite.Core.Tests.Deployment
     using System.IO;
     using System.Threading;
     using Apache.Ignite.Core.Cluster;
-    using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Compute;
     using Apache.Ignite.Core.Deployment;
     using Apache.Ignite.Core.Impl;
@@ -47,8 +46,10 @@ namespace Apache.Ignite.Core.Tests.Deployment
         {
             TestDeployment(remoteCompute =>
             {
-                var ex = Assert.Throws<IgniteException>(() => remoteCompute.Call(new ProcessNameFunc()));
+                var ex = Assert.Throws<AggregateException>(() => remoteCompute.Call(new ProcessNameFunc()))
+                    .InnerException;
 
+                Assert.IsNotNull(ex);
                 Assert.AreEqual("Compute job has failed on remote node, examine InnerException for details.", 
                     ex.Message);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
index 7d4c945..cb70f1e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
@@ -130,8 +130,9 @@ namespace Apache.Ignite.Core.Tests.Log
             {
                 var compute = ignite.GetCluster().ForRemotes().GetCompute();
 
-                var ex = Assert.Throws<IgniteException>(() => compute.Call(new FailFunc()));
-                Assert.IsInstanceOf<ArithmeticException>(ex.InnerException);
+                var ex = Assert.Throws<AggregateException>(() => compute.Call(new FailFunc()));
+                Assert.IsNotNull(ex.InnerException);
+                Assert.IsInstanceOf<ArithmeticException>(ex.InnerException.InnerException);
 
                 // Log updates may not arrive immediately
                 TestUtils.WaitForCondition(() => TestLogger.Entries.Any(x => x.Exception != null), 3000);

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs
index 5b6e5f1..b061be2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReflectiveActions.cs
@@ -226,7 +226,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                     : GetWriter<float>(field, (f, w, o) => w.WriteFloat(f, o));
                 readAction = raw ? GetRawReader(field, r => r.ReadFloat()) : GetReader(field, (f, r) => r.ReadFloat(f));
             }
-            else if (type == typeof (double))
+            else if (type == typeof(double))
             {
                 writeAction = raw
                     ? GetRawWriter<double>(field, (w, o) => w.WriteDouble(o))
@@ -236,7 +236,10 @@ namespace Apache.Ignite.Core.Impl.Binary
                     : GetReader(field, (f, r) => r.ReadDouble(f));
             }
             else
-                throw new IgniteException("Unsupported primitive type: " + type.Name);
+            {
+                throw new IgniteException(string.Format("Unsupported primitive type '{0}' [Field={1}, " +
+                                                        "DeclaringType={2}", type, field, field.DeclaringType));
+            }
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/618a448a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
index b69ad56..314e531 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -52,18 +52,10 @@ namespace Apache.Ignite.Core.Impl.Common
         /// <summary>
         /// Gets the result.
         /// </summary>
+        /// <exception cref="AggregateException" />
         public T Get()
         {
-            try
-            {
-                return Task.Result;
-            }
-            catch (AggregateException ex)
-            {
-                var innerEx = ex.InnerExceptions.Count > 1 ? ex : ex.InnerException;
-
-                throw new IgniteException("Async operation has failed, examine InnerException for details.", innerEx);
-            }
+            return Task.Result;
         }
 
         /// <summary>