diff --git a/logstash-core/lib/logstash/settings.rb b/logstash-core/lib/logstash/settings.rb index d5381c9779f..5d2fbd588df 100644 --- a/logstash-core/lib/logstash/settings.rb +++ b/logstash-core/lib/logstash/settings.rb @@ -154,7 +154,7 @@ def set_value(setting_name, value, graceful = false) def to_hash hash = {} @settings.each do |name, setting| - next if setting.kind_of? Setting::DeprecatedAlias + next if (setting.kind_of? Setting::DeprecatedAlias) || (setting.kind_of? Java::org.logstash.settings.DeprecatedAlias) hash[name] = setting.value end hash diff --git a/logstash-core/spec/logstash/settings_spec.rb b/logstash-core/spec/logstash/settings_spec.rb index 3e0b425dd46..31f67d38fcf 100644 --- a/logstash-core/spec/logstash/settings_spec.rb +++ b/logstash-core/spec/logstash/settings_spec.rb @@ -62,6 +62,28 @@ end end + describe "#to_hash" do + let(:java_deprecated_alias) { LogStash::Setting::Boolean.new("java.actual", true).with_deprecated_alias("java.deprecated") } + let(:ruby_deprecated_alias) { LogStash::Setting::PortRange.new("ruby.actual", 9600..9700).with_deprecated_alias("ruby.deprecated") } + let(:non_deprecated) { LogStash::Setting::Boolean.new("plain_setting", false) } + + before :each do + subject.register(java_deprecated_alias) + subject.register(ruby_deprecated_alias) + subject.register(non_deprecated) + end + + it "filter deprecated alias settings" do + generated_settings_hash = subject.to_hash + + expect(generated_settings_hash).not_to have_key("java.deprecated") + expect(generated_settings_hash).not_to have_key("ruby.deprecated") + expect(generated_settings_hash).to have_key("java.actual") + expect(generated_settings_hash).to have_key("ruby.actual") + expect(generated_settings_hash).to have_key("plain_setting") + end + end + describe "#get_subset" do let(:numeric_setting_1) { LogStash::Setting.new("num.1", Numeric, 1) } let(:numeric_setting_2) { LogStash::Setting.new("num.2", Numeric, 2) }