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 4EEB1200C82 for ; Fri, 12 May 2017 09:13:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4BF4E160BA3; Fri, 12 May 2017 07:13:51 +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 9AE1E160BB8 for ; Fri, 12 May 2017 09:13:50 +0200 (CEST) Received: (qmail 32638 invoked by uid 500); 12 May 2017 07:13:49 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 32565 invoked by uid 99); 12 May 2017 07:13:49 -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; Fri, 12 May 2017 07:13:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2F19ADFD43; Fri, 12 May 2017 07:13:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Fri, 12 May 2017 07:13:49 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/8] ignite git commit: IGNITE-5194 .NET: Fix TryGetIgnite to return an instance with any name when there is only one archived-at: Fri, 12 May 2017 07:13:51 -0000 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 Authored: Thu May 11 13:43:37 2017 +0300 Committer: Pavel Tupitsyn 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(() => 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 } /// - /// Gets an instance of default no-name grid, or null 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. /// /// An instance of default no-name grid, or null. public static IIgnite TryGetIgnite() { - return TryGetIgnite(null); + lock (SyncRoot) + { + if (Nodes.Count == 1) + { + return Nodes.Single().Value; + } + + return TryGetIgnite(null); + } } ///