-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement LogStash::Numeric setting in Java #17127
Reimplement LogStash::Numeric setting in Java #17127
Conversation
…are floats to use interval.
540bc2a
to
1cccfab
Compare
} | ||
|
||
@Override | ||
public Number coerce(Object obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the Ruby's version is handling nil
obj values, don't we need to do the same here for null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From irb
REPL on previous code I got:
> s.coerce(nil)
/Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/settings.rb:430:in `coerce': Failed to coerce value to Numeric. Received (NilClass) (ArgumentError)
so you are suggesting to add something
@Override
public Number coerce(Object obj) {
if (obj == null) {
throw new IllegalArgumentException("Failed to coerce value to SettingNumeric. Received null");
}
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, something like that, so we don't get a NPE (obj.toString()
) instead of an IllegalArgumentException when the value is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by e82f590
|
This pull request does not have a backport label. Could you fix it @andsel? 🙏
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Reimplements `LogStash::Setting::Numeric` Ruby setting class into the `org.logstash.settings.NumericSetting` and exposes it through `java_import` as `LogStash::Setting::NumericSetting`. Updates the rspec tests: - verifies `java.lang.IllegalArgumentException` instead of `ArgumentError` is thrown because the kind of exception thrown by Java code, during verification. (cherry picked from commit 07a3c8e)
…#17273) This is an automatic backport of pull request #17127 done by [Mergify](https://mergify.com). ---- * Reimplement LogStash::Numeric setting in Java (#17127) Reimplements `LogStash::Setting::Numeric` Ruby setting class into the `org.logstash.settings.NumericSetting` and exposes it through `java_import` as `LogStash::Setting::NumericSetting`. Updates the rspec tests: - verifies `java.lang.IllegalArgumentException` instead of `ArgumentError` is thrown because the kind of exception thrown by Java code, during verification. (cherry picked from commit 07a3c8e) * Fixed reference of SettingNumeric class (on main modules were removed) --------- Co-authored-by: Andrea Selva <[email protected]>
Release notes
[rn:skip]
What does this PR do?
Reimplements
LogStash::Setting::Numeric
Ruby setting class into theorg.logstash.settings.NumericSetting
and exposes it throughjava_import
asLogStash::Setting::NumericSetting
.Updates the rspec tests:
java.lang.IllegalArgumentException
instead ofArgumentError
is thrown because the kind of exception thrown by Java code, during verification.Why is it important/What is the impact to the user?
As a developer I want use Java classes to shape the configuration settings.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files (and/or docker env variables)Author's Checklist
How to test this PR locally
Update a numeric settings like
pipeline.batch.delay
to a value that's not the default, start Logstash and verify that the setting value is used, for example check withRelated issues