Skip to content

Avoid to run on JDK < 21 - #19311

Merged
andsel merged 3 commits into
elastic:8.19from
andsel:feature/reject_to_run_with_jdk_below_21
Jul 22, 2026
Merged

Avoid to run on JDK < 21#19311
andsel merged 3 commits into
elastic:8.19from
andsel:feature/reject_to_run_with_jdk_below_21

Conversation

@andsel

@andsel andsel commented Jul 16, 2026

Copy link
Copy Markdown
Member

Release notes

Checks that the minimum required JDK is verified. Avoid to run on JDK below 21.

What does this PR do?

Updates runner.rb to do a JDK version check. In case the recognised JDK version is below 21 logs an error message and exit.
At the same time permit to manually force the check , reading the logstash.jdk.force from JVM options. Set -Dlogstash.jdk.force=true either in config/jvm.options or LS_JAVA_OPTS to run Logstash. If this condition is met a warn message is logged and execution proceed as usual.

Why is it important/What is the impact to the user?

A user should always use verified and supported JDK version. Starting from 8.19.19 the JDK 17 is deprecated and the suggested (and bundled) one is JDK 21. If the user customized his Java, setting LS_JAVA_HOME, to an unsupported version, Logstash stops. This can be manually forced setting -Dlogstash.jdk.force=true in either LS_JAVA_OPTS or in the config/jvm.options.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • [ ] I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Verify that with unsupported JDK version, Logstash logs an error and refuse to start.

LS_JAVA_HOME="/path/to/java/17.0.19-tem" bin/logstash -e "input{stdin{}} output{stdout{}}"

Verify that with unsupported JDK version AND manually forcing it, Logstash logs a warning and start.

LS_JAVA_HOME="/path/to/java/17.0.19-tem" LS_JAVA_OPTS="-Dlogstash.jdk.force=true"  bin/logstash -e "input{stdin{}} output{stdout{}}"

Related issues

Logs

Example execution avoidance:

Using LS_JAVA_HOME defined java: /Users/andreaselva/.sdkman/candidates/java/17.0.19-tem.
Sending Logstash logs to /Users/andreaselva/workspace/logstash_andsel/logs which is now configured via log4j2.properties
[2026-07-16T11:24:39,161][INFO ][logstash.runner          ] Log4j configuration path used is: /Users/andreaselva/workspace/logstash_andsel/config/log4j2.properties
[2026-07-16T11:24:39,164][ERROR][logstash.runner          ] Starting from Logstash 8.19.19 the minimum required version of Java is 21; your Java version from `/Users/andreaselva/.sdkman/candidates/java/17.0.19-tem` is `17` and does not meet this requirement. Running Logstash with the bundled JDK is recommended. The bundled JDK has been verified to work with each specific version of Logstash, and generally provides best performance and reliability. If you have compelling reasons for using your own JDK (organizational-specific compliance requirements, for example), the version you supply with LS_JAVA_HOME must meet the minimum requirements.
[2026-07-16T11:24:39,169][FATAL][org.logstash.Logstash    ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
	at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:928)
	at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:887)
	at Users.andreaselva.workspace.logstash_andsel.lib.bootstrap.environment.<main>(/Users/andreaselva/workspace/logstash_andsel/lib/bootstrap/environment.rb:90)

Example with manual force:

[2026-07-16T11:19:00,700][INFO ][logstash.runner          ] Log4j configuration path used is: /Users/andreaselva/workspace/logstash_andsel/config/log4j2.properties
[2026-07-16T11:19:00,703][WARN ][logstash.runner          ] Starting from Logstash 8.19.19 the minimum required version of Java is 21; your Java version from `/Users/andreaselva/.sdkman/candidates/java/17.0.19-tem` is `17` and does not meet this requirement. You have selected to force the execution with unsupported Java version, and could generate unexpected malfunctions. Running Logstash with the bundled JDK is recommended. The bundled JDK has been verified to work with each specific version of Logstash, and generally provides best performance and reliability. If you have compelling reasons for using your own JDK (organizational-specific compliance requirements, for example), the version you supply with LS_JAVA_HOME must meet the minimum requirements.
[2026-07-16T11:19:00,704][WARN ][logstash.runner          ] The use of JAVA_HOME has been deprecated. Logstash 8.0 and later ignores JAVA_HOME and uses the bundled JDK. Running Logstash with the bundled JDK is recommended. The bundled JDK has been verified to work with each specific version of Logstash, and generally provides best performance and reliability. If you have compelling reasons for using your own JDK (organizational-specific compliance requirements, for example), you can configure LS_JAVA_HOME to use that version instead.
[2026-07-16T11:19:00,704][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"8.19.19", "jruby.version"=>"jruby 9.4.15.0 (3.1.7) 2026-06-08 6114208a31 OpenJDK 64-Bit Server VM 17.0.19+10 on 17.0.19+10 +indy +jit [arm64-darwin]"}
[2026-07-16T11:19:00,704][INFO ][logstash.runner          ] JVM bootstrap flags: [-Xms1g, -Xmx1g, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djruby.compile.invokedynamic=true, -XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom, -Dlog4j2.isThreadContextMapInheritable=true, -Dlogstash.jdk.force=true, -Djruby.regexp.interruptible=true, -Djdk.io.File.enableADS=true, --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED, --add-opens=java.base/java.security=ALL-UNNAMED, --add-opens=java.base/java.io=ALL-UNNAMED, --add-opens=java.base/java.nio.channels=ALL-UNNAMED, --add-opens=java.base/sun.nio.ch=ALL-UNNAMED, --add-opens=java.management/sun.management=ALL-UNNAMED, -Dio.netty.allocator.maxOrder=11]

@andsel andsel self-assigned this Jul 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • run exhaustive tests : Run the exhaustive tests Buildkite pipeline.

@andsel andsel linked an issue Jul 16, 2026 that may be closed by this pull request
@andsel
andsel marked this pull request as ready for review July 16, 2026 09:35
@donoghuc
donoghuc self-requested a review July 16, 2026 15:28
@donoghuc

Copy link
Copy Markdown
Member

run exhaustive tests

@donoghuc donoghuc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we need to adjust jdk matrix buildkite tests? For 8.19 we seem to be testing against java 17, i think that we will need to either do the override for now in test? Or should we just stop testing on 17 now?

@andsel

andsel commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

#19291 already contains a backport of #16464 that update the CI moving from JDK17 to JDK21.

If we run the exhaustive test on JDK17, this PR should fail (I would expect) because it exist the Logstash run if JDK 17 is detected 🤔

@andsel

andsel commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

I answered myself, the acceptance tests, run the LS package, which bundles JDK 21 on 8.19, so JDK 17 is used to execute Gradle etc but then when LS process is spawn it runs the JDK 21.

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @andsel

@andsel

andsel commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

The execution before 88d413b showed the problme: https://buildkite.com/elastic/logstash-linux-jdk-matrix-pipeline/builds/812.

@donoghuc fixed please give it another eye if you can.

@andsel
andsel requested a review from donoghuc July 20, 2026 12:05
@andsel
andsel merged commit 1b9db53 into elastic:8.19 Jul 22, 2026
6 checks passed
andsel pushed a commit that referenced this pull request Aug 4, 2026
Reverts addition of `logstash.jdk.force` and all references to it while we figure out the best ergonomics and deprecation path. The behavior should remain the same as in 8.19.19 whereby if a custom jdk 17 is detected a deprecation will be logged and logstash will continue to run normally.  


Reverts #19311 #19361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent Logstash from starting by default if JDK17 is detected.

2 participants