diff --git a/.buildkite/linux_jdk_matrix_pipeline.yml b/.buildkite/linux_jdk_matrix_pipeline.yml index f19cb69691..206017d35c 100644 --- a/.buildkite/linux_jdk_matrix_pipeline.yml +++ b/.buildkite/linux_jdk_matrix_pipeline.yml @@ -68,16 +68,8 @@ steps: value: "adoptiumjdk_11" - label: "OpenJDK 21" value: "openjdk_21" - - label: "OpenJDK 17" - value: "openjdk_17" - - label: "OpenJDK 11" - value: "openjdk_11" - label: "Zulu 21" value: "zulu_21" - - label: "Zulu 17" - value: "zulu_17" - - label: "Zulu 11" - value: "zulu_11" - wait: ~ if: build.source != "schedule" && build.source != "trigger_job" diff --git a/.buildkite/windows_jdk_matrix_pipeline.yml b/.buildkite/windows_jdk_matrix_pipeline.yml index 34c8123381..54b4f4c939 100644 --- a/.buildkite/windows_jdk_matrix_pipeline.yml +++ b/.buildkite/windows_jdk_matrix_pipeline.yml @@ -33,22 +33,10 @@ steps: options: - label: "Adoptium JDK 21 (Eclipse Temurin)" value: "adoptiumjdk_21" - - label: "Adoptium JDK 17 (Eclipse Temurin)" - value: "adoptiumjdk_17" - - label: "Adoptium JDK 11 (Eclipse Temurin)" - value: "adoptiumjdk_11" - label: "OpenJDK 21" value: "openjdk_21" - - label: "OpenJDK 17" - value: "openjdk_17" - - label: "OpenJDK 11" - value: "openjdk_11" - label: "Zulu 21" value: "zulu_21" - - label: "Zulu 17" - value: "zulu_17" - - label: "Zulu 11" - value: "zulu_11" - wait: ~ if: build.source != "schedule" && build.source != "trigger_job" diff --git a/config/jvm.options b/config/jvm.options index a00db32e9a..0a247b4383 100644 --- a/config/jvm.options +++ b/config/jvm.options @@ -87,4 +87,9 @@ # # Sets the maximum nesting depth. The depth is a count of objects and arrays that have not # been closed, `{` and `[` respectively. -#-Dlogstash.jackson.stream-read-constraints.max-nesting-depth=1000 \ No newline at end of file +#-Dlogstash.jackson.stream-read-constraints.max-nesting-depth=1000 + +# Bypass JDK version check +# +# Setting this to true permit to run Logstash with an unsupported JDK version. +#-Dlogstash.jdk.force=true \ No newline at end of file diff --git a/logstash-core/lib/logstash/runner.rb b/logstash-core/lib/logstash/runner.rb index 50447e6563..f907678dcc 100644 --- a/logstash-core/lib/logstash/runner.rb +++ b/logstash-core/lib/logstash/runner.rb @@ -331,6 +331,7 @@ def execute deprecation_logger.deprecated msg end + jvmArgs = ManagementFactory.getRuntimeMXBean().getInputArguments() if JavaVersion::CURRENT < JavaVersion::JAVA_11 logger.warn I18n.t("logstash.runner.java.version", :java_home => java.lang.System.getProperty("java.home")) @@ -338,8 +339,16 @@ def execute deprecation_logger.deprecated I18n.t("logstash.runner.java.version_17_minimum", :java_home => java.lang.System.getProperty("java.home")) elsif JavaVersion::CURRENT < JavaVersion::JAVA_21 - deprecation_logger.deprecated I18n.t("logstash.runner.java.version_21_minimum", - :java_home => java.lang.System.getProperty("java.home")) + if force_jdk_check(jvmArgs) + logger.warn I18n.t("logstash.runner.java.version_below_21_force", + :java_home => java.lang.System.getProperty("java.home"), + :java_version => JavaVersion::CURRENT) + else + logger.error I18n.t("logstash.runner.java.version_21_minimum", + :java_home => java.lang.System.getProperty("java.home"), + :java_version => JavaVersion::CURRENT) + return 1 + end end logger.warn I18n.t("logstash.runner.java.home") if ENV["JAVA_HOME"] @@ -350,7 +359,6 @@ def execute end logger.info("Starting Logstash", "logstash.version" => LOGSTASH_VERSION, "jruby.version" => RUBY_DESCRIPTION) - jvmArgs = ManagementFactory.getRuntimeMXBean().getInputArguments() logger.info "JVM bootstrap flags: #{jvmArgs}" # Add local modules to the registry before everything else @@ -650,4 +658,8 @@ def configure_pipeline_buffer_type end end + def force_jdk_check(jvm_args_list) + jvm_args_list.include? "-Dlogstash.jdk.force=true" + end + private :force_jdk_check end diff --git a/logstash-core/locales/en.yml b/logstash-core/locales/en.yml index 03a6d73ce2..ba09f89709 100644 --- a/logstash-core/locales/en.yml +++ b/logstash-core/locales/en.yml @@ -453,8 +453,15 @@ en: 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. version_21_minimum: >- - Java 17 is deprecated and in a future release the minimum required version of Java will be Java 21; - your Java version from `%{java_home}` does not meet this requirement. + Starting from Logstash 8.19.19 the minimum required version of Java is 21; + your Java version from `%{java_home}` is `%{java_version}` 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. + version_below_21_force: >- + Starting from Logstash 8.19.19 the minimum required version of Java is 21; + your Java version from `%{java_home}` is `%{java_version}` 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. diff --git a/logstash-core/src/main/java/org/logstash/util/JavaVersion.java b/logstash-core/src/main/java/org/logstash/util/JavaVersion.java index 2671b38a1b..a4d08eefd7 100644 --- a/logstash-core/src/main/java/org/logstash/util/JavaVersion.java +++ b/logstash-core/src/main/java/org/logstash/util/JavaVersion.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * Helper class to compare current version of JVM with a target version. @@ -84,4 +85,9 @@ private static int compare(final JavaVersion leftVersion, final JavaVersion righ public int compareTo(JavaVersion other) { return compare(this, other); } + + @Override + public String toString() { + return version.stream().map(Object::toString).collect(Collectors.joining(".")); + } } \ No newline at end of file