ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/8] ignite git commit: IGNITE-5194 .NET: Fix TryGetIgnite to return an instance with any name when there is only one
Date Fri, 12 May 2017 07:13:49 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-5075-cacheStart e0e587864 -> 3762b0dd8


IGNITE-5194 .NET: Fix TryGetIgnite to return an instance with any name when there is only
one


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

Branch: refs/heads/ignite-5075-cacheStart
Commit: f0051e18add681e613efe9420c99d7f5c438a192
Parents: 57c6705
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu May 11 13:43:37 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Thu May 11 13:43:37 2017 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.Core.Tests/IgniteStartStopTest.cs |  2 ++
 .../platforms/dotnet/Apache.Ignite.Core/Ignition.cs | 16 ++++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f0051e18/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
index 486878a..529128a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs
@@ -185,9 +185,11 @@ namespace Apache.Ignite.Core.Tests
 
             Ignition.Start(cfg);
             Assert.IsNotNull(Ignition.GetIgnite());
+            Assert.IsNotNull(Ignition.TryGetIgnite());
 
             Ignition.Start(cfg);
             Assert.Throws<IgniteException>(() => Ignition.GetIgnite());
+            Assert.IsNull(Ignition.TryGetIgnite());
             Assert.AreEqual(2, Ignition.GetAll().Count);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f0051e18/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index cdb1064..fdddbb7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -651,14 +651,22 @@ namespace Apache.Ignite.Core
         }
 
         /// <summary>
-        /// Gets an instance of default no-name grid, or <c>null</c> if none
found. Note that
-        /// caller of this method should not assume that it will return the same
-        /// instance every time.
+        /// Gets the default Ignite instance with null name, or an instance with any name
when there is only one.
+        /// Returns null when there are no Ignite instances started, or when there are more
than one,
+        /// and none of them has null name.
         /// </summary>
         /// <returns>An instance of default no-name grid, or null.</returns>
         public static IIgnite TryGetIgnite()
         {
-            return TryGetIgnite(null);
+            lock (SyncRoot)
+            {
+                if (Nodes.Count == 1)
+                {
+                    return Nodes.Single().Value;
+                }
+
+                return TryGetIgnite(null);
+            }
         }
 
         /// <summary>


Mime
View raw message