mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Add deprecation warnings for JAVA_HOME/older versions of Java (#13358)
* Add deprecation warnings for JAVA_HOME/older versions of Java Logstash 8.0 will remove support for java versions before java 11, this commit adds entries to the deprecation log warning against this. Also adds use of `JAVA_HOME` to the deprecation log.
This commit is contained in:
parent
7952046eb8
commit
c612afa5ef
3 changed files with 103 additions and 1 deletions
|
@ -14,7 +14,7 @@
|
|||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
java_import 'org.logstash.util.JavaVersion'
|
||||
Thread.abort_on_exception = true
|
||||
Encoding.default_external = Encoding::UTF_8
|
||||
$DEBUGLIST = (ENV["DEBUG"] || "").split(",")
|
||||
|
@ -326,6 +326,12 @@ class LogStash::Runner < Clamp::StrictCommand
|
|||
deprecation_logger.deprecated msg
|
||||
end
|
||||
|
||||
if JavaVersion::CURRENT < JavaVersion::JAVA_11
|
||||
deprecation_logger.deprecated I18n.t("logstash.runner.java.version",
|
||||
:java_home => java.lang.System.getProperty("java.home"))
|
||||
end
|
||||
|
||||
deprecation_logger.deprecated I18n.t("logstash.runner.java.home") if ENV["JAVA_HOME"]
|
||||
# Skip any validation and just return the version
|
||||
if version?
|
||||
show_version
|
||||
|
|
|
@ -433,6 +433,18 @@ en:
|
|||
quiet: |+
|
||||
Set the log level to info.
|
||||
DEPRECATED: use --log.level=info instead.
|
||||
java:
|
||||
home: >-
|
||||
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.
|
||||
version: >-
|
||||
Starting from Logstash 8.0, the minimum required version of Java is Java 11; your Java version from
|
||||
%{java_home} does not meet this requirement. Please reconfigure your version of Java to one that is supported.
|
||||
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.
|
||||
settings:
|
||||
deprecation:
|
||||
set: >-
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.logstash.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Helper class to compare current version of JVM with a target version.
|
||||
* Based on JavaVersion class from elasticsearch java version checker tool
|
||||
*/
|
||||
public class JavaVersion implements Comparable<JavaVersion> {
|
||||
|
||||
public static final JavaVersion CURRENT = parse(System.getProperty("java.specification.version"));
|
||||
public static final JavaVersion JAVA_11 = parse("11");
|
||||
private final List<Integer> version;
|
||||
|
||||
private JavaVersion(List<Integer> version){
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
static JavaVersion parse(final String value) {
|
||||
if (value.matches("^0*[0-9]+(\\.[0-9]+)*$") == false) {
|
||||
throw new IllegalArgumentException(value);
|
||||
}
|
||||
|
||||
final List<Integer> version = new ArrayList<Integer>();
|
||||
final String[] components = value.split("\\.");
|
||||
for (final String component : components) {
|
||||
version.add(Integer.valueOf(component));
|
||||
}
|
||||
return new JavaVersion(version);
|
||||
}
|
||||
|
||||
public static int majorVersion(final JavaVersion javaVersion) {
|
||||
Objects.requireNonNull(javaVersion);
|
||||
if (javaVersion.version.get(0) > 1) {
|
||||
return javaVersion.version.get(0);
|
||||
} else {
|
||||
return javaVersion.version.get(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static int compare(final JavaVersion leftVersion, final JavaVersion rightVersion) {
|
||||
List<Integer> left = leftVersion.version;
|
||||
List<Integer> right = rightVersion.version;
|
||||
// lexicographically compare two lists, treating missing entries as zeros
|
||||
final int len = Math.max(left.size(), right.size());
|
||||
for (int i = 0; i < len; i++) {
|
||||
final int l = (i < left.size()) ? left.get(i) : 0;
|
||||
final int r = (i < right.size()) ? right.get(i) : 0;
|
||||
if (l < r) {
|
||||
return -1;
|
||||
}
|
||||
if (r < l) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(JavaVersion other) {
|
||||
return compare(this, other);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue