Backport PR #15679 to 8.x: [Spacetime] Reimplement config Setting classe in java#16490
Merged
Backport PR #15679 to 8.x: [Spacetime] Reimplement config Setting classe in java#16490
Conversation
Reimplement the root Ruby Setting class in Java and use it from the Ruby one moving the original Ruby class to a shell wrapping the Java instance. In particular create a new symmetric hierarchy (at the time just for `Setting`, `Coercible` and `Boolean` classes) to the Ruby one, moving also the feature for setting deprecation. In this way the new `org.logstash.settings.Boolean` is syntactically and semantically equivalent to the old Ruby Boolean class, which replaces. (cherry picked from commit 61de60f)
|
💛 Build succeeded, but was flaky
Failed CI StepsHistory
|
Merged
yaauie
approved these changes
Oct 10, 2024
Member
There was a problem hiding this comment.
LGTM for a merge, because getting these in sync is better than perfection.
I think that the this-escape can be avoided, but that it doesn't present a present danger and we can do so in a follow-up effort.
- introduce package-private static
BaseSetting#validate(T, Predicate<T>):void static validateValue(String name, T input, Predicate<T> validator) throws IllegalArgumentException { if (!validator.test(input)) { throw new IllegalArgumentException(String.format("Failed to validate setting `%s` with value: `%s`", name, input); } }
- migrate the instance method
BaseSetting#validate(T)and the validate-in-initializer calls to use the static method:public void validate(T input) throws IllegalArgumentException { validateValue(this.name, input, this.validator); }
// protected BaseSetting(String name, T defaultValue, boolean strict, Predicate<T> validator) { // ... if (strict) { validateValue(name, input, validator); } // }
// protected Coercible(...) { if (strict) { T coercedDefault = coerce(defaultValue); BaseSetting.validateValue(name, coercedDefault, validator); this.defaultValue = coercedDefault; } else { this.defaultValue = defaultValue; } // }
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Backport PR #15679 to 8.x branch, original message:
Release notes
[rn:skip]
What does this PR do?
This is a not clean backport of #15679 to
8.xbranch.It adds the commit 5ca0686 to avoid errors like
happening with JDK 21 https://buildkite.com/elastic/logstash-pull-request-pipeline/builds/1524#01924c14-d87e-45ac-8b4f-a5e365b9d474/62-651