Skip to content

Commit 35d3d93

Browse files
committed
Fixed nullable specs after the usage of the new Java StringSetting instead of Ruby one
1 parent 0c311c7 commit 35d3d93

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

logstash-core/lib/logstash/settings.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ def validate(value)
827827
end
828828
end
829829

830+
java_import org.logstash.settings.NullableSetting
831+
830832
# @see Setting#nullable
831833
# @api internal
832834
class Nullable < SimpleDelegator

logstash-core/lib/logstash/util/settings_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module LogStash::Util::SettingsHelper
3333
# The `path.settings` and `path.logs` can not be defined in "logstash/environment" since the `Environment::LOGSTASH_HOME` doesn't
3434
# exist unless launched via "bootstrap/environment"
3535
def self.pre_process
36-
LogStash::SETTINGS.register(LogStash::Setting::String.new("path.settings", ::File.join(LogStash::Environment::LOGSTASH_HOME, "config")))
37-
LogStash::SETTINGS.register(LogStash::Setting::String.new("path.logs", ::File.join(LogStash::Environment::LOGSTASH_HOME, "logs")))
36+
LogStash::SETTINGS.register(LogStash::Setting::StringSetting.new("path.settings", ::File.join(LogStash::Environment::LOGSTASH_HOME, "config")))
37+
LogStash::SETTINGS.register(LogStash::Setting::StringSetting.new("path.logs", ::File.join(LogStash::Environment::LOGSTASH_HOME, "logs")))
3838
end
3939

4040
# Ensure that any settings are re-calculated after loading yaml

logstash-core/spec/logstash/settings/nullable_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020

2121
describe LogStash::Setting::Nullable do
2222
let(:setting_name) { "this.that" }
23-
let(:normal_setting) { LogStash::Setting::String.new(setting_name, nil, false, possible_strings) }
23+
let(:normal_setting) { LogStash::Setting::StringSetting.new(setting_name, nil, false, possible_strings) }
2424
let(:possible_strings) { [] } # empty means any string passes
2525

2626
subject(:nullable_setting) { normal_setting.nullable }
2727

2828
it 'is a kind of Nullable' do
29-
expect(nullable_setting).to be_a_kind_of(described_class)
29+
expect(nullable_setting).to be_a_kind_of(LogStash::Setting::NullableSetting)
3030
end
3131

3232
it "retains the wrapped setting's name" do
@@ -56,14 +56,14 @@
5656
context 'to an invalid wrong-type value' do
5757
let(:candidate_value) { 127 } # wrong type, expects String
5858
it 'is an invalid setting' do
59-
expect { nullable_setting.validate_value }.to raise_error(ArgumentError, a_string_including("Setting \"#{setting_name}\" must be a "))
59+
expect { nullable_setting.validate_value }.to raise_error(java.lang.ClassCastException, a_string_including("class java.lang.Long cannot be cast to class java.lang.String"))
6060
end
6161
end
6262
context 'to an invalid value not in the allow-list' do
6363
let(:possible_strings) { %w(this that)}
6464
let(:candidate_value) { "another" } # wrong type, expects String
6565
it 'is an invalid setting' do
66-
expect { nullable_setting.validate_value }.to raise_error(ArgumentError, a_string_including("Invalid value"))
66+
expect { nullable_setting.validate_value }.to raise_error(java.lang.IllegalArgumentException, a_string_including("Invalid value"))
6767
end
6868
end
6969
context 'to a valid value' do

0 commit comments

Comments
 (0)