From d9541d53eaf0a9bf3176ed77ff57b00fc27490a0 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Wed, 13 Jan 2021 16:15:51 +0000 Subject: [PATCH] Fix bug in AutoExpandReplicas.Create The create method was not allowing the valid value of "false. Fixes #5258 --- .../IndexSettings/Settings/AutoExpandReplicas.cs | 3 +++ .../AutoExpandReplicas/AutoExpandReplicasTests.cs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Nest/IndexModules/IndexSettings/Settings/AutoExpandReplicas.cs b/src/Nest/IndexModules/IndexSettings/Settings/AutoExpandReplicas.cs index 73cba0bf949..a3d4ed03e87 100644 --- a/src/Nest/IndexModules/IndexSettings/Settings/AutoExpandReplicas.cs +++ b/src/Nest/IndexModules/IndexSettings/Settings/AutoExpandReplicas.cs @@ -98,6 +98,9 @@ public static AutoExpandReplicas Create(string value) if (value.IsNullOrEmpty()) throw new ArgumentException("cannot be null or empty", nameof(value)); + if (value.Equals("false", StringComparison.OrdinalIgnoreCase)) + return Disabled; + var expandReplicaParts = value.Split('-'); if (expandReplicaParts.Length != 2) throw new ArgumentException("must contain a 'from' and 'to' value", nameof(value)); diff --git a/tests/Tests/CommonOptions/AutoExpandReplicas/AutoExpandReplicasTests.cs b/tests/Tests/CommonOptions/AutoExpandReplicas/AutoExpandReplicasTests.cs index 5ab4f96d579..b882342362c 100644 --- a/tests/Tests/CommonOptions/AutoExpandReplicas/AutoExpandReplicasTests.cs +++ b/tests/Tests/CommonOptions/AutoExpandReplicas/AutoExpandReplicasTests.cs @@ -77,6 +77,17 @@ public void CreateWithMinAndAll() autoExpandReplicas.ToString().Should().Be("0-all"); } + [U] + public void CreateWithFalse() + { + var autoExpandReplicas = Nest.AutoExpandReplicas.Create("false"); + autoExpandReplicas.Should().NotBeNull(); + autoExpandReplicas.Enabled.Should().BeFalse(); + autoExpandReplicas.MinReplicas.Should().BeNull(); + autoExpandReplicas.MaxReplicas.Should().BeNull(); + autoExpandReplicas.ToString().Should().Be("false"); + } + [U] public void Disabled() {