From fb13b3325382fbd490766b35c07f2f75750db1c1 Mon Sep 17 00:00:00 2001 From: mrrd Date: Thu, 11 Jan 2018 19:00:11 +0000 Subject: [PATCH] Update SplitBrainResolver.cs (#3266) * Fix exception that can occur when remaining and unreachable variables both have zero elements --- src/core/Akka.Cluster/SplitBrainResolver.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/Akka.Cluster/SplitBrainResolver.cs b/src/core/Akka.Cluster/SplitBrainResolver.cs index 79783141ddb..6dfc8bd00b3 100644 --- a/src/core/Akka.Cluster/SplitBrainResolver.cs +++ b/src/core/Akka.Cluster/SplitBrainResolver.cs @@ -133,15 +133,14 @@ public IEnumerable Apply(NetworkPartitionContext context) var unreachable = MembersWithRole(context.Unreachable); if (remaining.Count < unreachable.Count) return context.Remaining; - else if (remaining.Count > unreachable.Count) return context.Unreachable; - else - { - // if the parts are of equal size the part containing the node with the lowest address is kept. - var oldest = remaining.Union(unreachable).First(); - return remaining.Contains(oldest) - ? context.Unreachable - : context.Remaining; - } + if (remaining.Count > unreachable.Count) return context.Unreachable; + if (remaining.IsEmpty && unreachable.IsEmpty) return new Member[0]; + + // if the parts are of equal size the part containing the node with the lowest address is kept. + var oldest = remaining.Union(unreachable).First(); + return remaining.Contains(oldest) + ? context.Unreachable + : context.Remaining; } private ImmutableSortedSet MembersWithRole(ImmutableSortedSet members) => string.IsNullOrEmpty(Role) @@ -341,4 +340,4 @@ private void ResetStabilityTimeout() _stabilityTask = Context.System.Scheduler.ScheduleTellOnceCancelable(_stabilityTimeout, Self, StabilityReached.Instance, ActorRefs.NoSender); } } -} \ No newline at end of file +}