Avoid SuppressWarnings of "this-escape" in Java Setting hierarchy
- Dominant language
- Java
- Stars
- 14.9k
- Forks
- 3.5k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 88
Description
With #16496 and commit 5ca068693a6cbec28bf794cb1cf6f560c5053351 in #16490 were introduced some `@SupressWarning` annotations to avoid errors with JDK 21 like:
```
/buildkite/builds/bk-agent-prod-k8s-1728654414425952824/elastic/logstash-pull-request-pipeline/logstash-core/src/main/java/org/logstash/settings/BaseSetting.java:105: warning: [this-escape] possible 'this' escape before subclass is fully initialized
--
| validate(defaultValue);
| ^pileJava
| error: warnings found and -Werror specified
| 1 error
| 1 warning
|
| > Task :logstash-core:compileJava FAILED
|
| FAILURE: Build failed with an exception.
```
As per comment https://github.com/elastic/logstash/pull/16490#pullrequestreview-2360999039 this issue is to ask for removal of such annotations and leverage static method instead of calling instance methods on non-completely initialised instances.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with logstash-core/src/main/java/org/logstash/settings/BaseSetting.java and inspect the warning location around validate(defaultValue). Review the suppress-warning annotations introduced by #16496 and commit 5ca068693a6cbec28bf794cb1cf6f560c5053351, along with linked PR #16543. Done means removing the relevant annotations and avoiding instance-method calls during incomplete initialization by using static methods where appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100