Skip to content

Commit

Permalink
Fix: delegating from deprecated setting (#13481)
Browse files Browse the repository at this point in the history
  • Loading branch information
kares authored Dec 8, 2021
1 parent 0cba1e5 commit 32b8739
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion logstash-core/lib/logstash/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ def value

def validate_value
# bypass deprecation warning
validate(wrapped.value) if set?
wrapped.validate_value if set?
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,45 @@
end

context "when only the deprecated alias is set" do

let(:value) { "crusty_value" }

before(:each) do
settings.set(deprecated_setting_name, "crusty_value")
settings.set(deprecated_setting_name, value)
end

it 'resolves to the value provided for the deprecated alias' do
expect(settings.get(canonical_setting_name)).to eq("crusty_value")
expect(settings.get(canonical_setting_name)).to eq(value)
end

it 'logs a deprecation warning' do
expect(LogStash::Settings.deprecation_logger).to have_received(:deprecated).with(a_string_including(deprecated_setting_name))
end

include_examples '#validate_value success'

it 'validates deprecated alias' do
expect { settings.get_setting(canonical_setting_name).deprecated_alias.validate_value }.to_not raise_error
end

context 'using a boolean setting' do

let(:value) { true }
let(:default_value) { false }

let(:canonical_setting) { LogStash::Setting::Boolean.new(canonical_setting_name, default_value, true) }

it 'resolves to the value provided for the deprecated alias' do
expect(settings.get(canonical_setting_name)).to eq(true)
end

include_examples '#validate_value success'

it 'validates deprecated alias' do
expect { settings.get_setting(canonical_setting_name).deprecated_alias.validate_value }.to_not raise_error
end

end
end

context "when only the canonical setting is set" do
Expand Down

0 comments on commit 32b8739

Please sign in to comment.