Skip to content

Commit

Permalink
Require Java 17 for running Elasticsearch (#79873)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Oct 27, 2021
1 parent b776087 commit 26c8687
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .ci/java-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# are 'java' or 'openjdk' followed by the major release number.

ES_BUILD_JAVA=openjdk16
ES_RUNTIME_JAVA=java11
ES_RUNTIME_JAVA=openjdk17
5 changes: 0 additions & 5 deletions .ci/matrix-runtime-javas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,4 @@
# or 'openjdk' followed by the major release number.

ES_RUNTIME_JAVA:
- java11
- openjdk16
- zulu11
- corretto11
- adoptopenjdk11
- openjdk17
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ configure(allprojects) {
test.executable = rootProject.jdks.provisioned_runtime.getBinJavaPath()
}
}
project.plugins.withId("elasticsearch.testclusters") { testClustersPlugin ->
project.plugins.withId("elasticsearch.internal-testclusters") { internalPlugin ->
if (BuildParams.getIsRuntimeJavaHomeSet() == false) {
// If no runtime java home is set, use the bundled JDK for test clusters
testClustersPlugin.setRuntimeJava(providers.provider(() -> file("${rootProject.jdks.provisioned_runtime.javaHomePath}")))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,23 @@ public void apply(Project project) {
JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(getResourceContents("/minimumRuntimeVersion"));

File runtimeJavaHome = findRuntimeJavaHome();
boolean isRuntimeJavaHomeSet = Jvm.current().getJavaHome().equals(runtimeJavaHome) == false;

File rootDir = project.getRootDir();
GitInfo gitInfo = GitInfo.gitInfo(rootDir);

BuildParams.init(params -> {
params.reset();
params.setRuntimeJavaHome(runtimeJavaHome);
params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion));
params.setIsRuntimeJavaHomeSet(Jvm.current().getJavaHome().equals(runtimeJavaHome) == false);
// TODO: Temporarily hard-code this to 17 until we upgrade to Gradle 7.3 and bump minimumRuntimeVersion
params.setRuntimeJavaVersion(
determineJavaVersion(
"runtime java.home",
runtimeJavaHome,
isRuntimeJavaHomeSet ? JavaVersion.VERSION_17 : Jvm.current().getJavaVersion()
)
);
params.setIsRuntimeJavaHomeSet(isRuntimeJavaHomeSet);
JvmInstallationMetadata runtimeJdkMetaData = metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome).getLocation());
params.setRuntimeJavaDetails(formatJavaVendorDetails(runtimeJdkMetaData));
params.setJavaVersions(getAvailableJavaVersions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
* This class defines gradle tasks for testing our various distribution artifacts.
*/
public class DistroTestPlugin implements Plugin<Project> {
private static final String SYSTEM_JDK_VERSION = "11.0.2+9";
private static final String SYSTEM_JDK_VENDOR = "openjdk";
private static final String SYSTEM_JDK_VERSION = "17+35";
private static final String SYSTEM_JDK_VENDOR = "adoptium";
private static final String GRADLE_JDK_VERSION = "16.0.2+7";
private static final String GRADLE_JDK_VENDOR = "adoptium";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class JavaVersion {

public static final List<Integer> CURRENT = parse(System.getProperty("java.specification.version"));
public static final List<Integer> JAVA_11 = parse("11");
public static final List<Integer> JAVA_17 = parse("17");

static List<Integer> parse(final String value) {
if (value.matches("^0*[0-9]+(\\.[0-9]+)*$") == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import java.util.Locale;

/**
* Simple program that checks if the runtime Java version is at least 1.8.
* Simple program that checks if the runtime Java version is at least 17.
*/
final class JavaVersionChecker {

private JavaVersionChecker() {}

/**
* The main entry point. The exit code is 0 if the Java version is at least 1.8, otherwise the exit code is 1.
* The main entry point. The exit code is 0 if the Java version is at least 17, otherwise the exit code is 1.
*
* @param args the args to the program which are rejected if not empty
*/
Expand All @@ -28,10 +28,10 @@ public static void main(final String[] args) {
if (args.length != 0) {
throw new IllegalArgumentException("expected zero arguments but was " + Arrays.toString(args));
}
if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_11) < 0) {
if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_17) < 0) {
final String message = String.format(
Locale.ROOT,
"the minimum required Java version is 11; your Java version from [%s] does not meet this requirement",
"The minimum required Java version is 17; your Java version from [%s] does not meet this requirement",
System.getProperty("java.home")
);
errPrintln(message);
Expand Down
21 changes: 21 additions & 0 deletions docs/changelog/79873.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pr: 79873
summary: Require Java 17 for running Elasticsearch
area: Packaging
type: breaking
issues: []
breaking:
title: Require Java 17 for running Elasticsearch
area: Packaging
details: |-
Java 17 or higher is now required to run Elasticsearch and any of its command
line tools.
impact: |-
Use Java 17 or higher. Attempts to run Elasticsearch 8.0 using earlier Java versions will
fail.
There is not yet a FIPS-certified security module for Java 17
that you can use when running Elasticsearch 8.0 in FIPS 140-2 mode.
If you run in FIPS 140-2 mode, you will either need to request an exception
from your security organization to upgrade to Elasticsearch 8.0,
or remain on Elasticsearch 7.x until Java 17 is certified.
notable: true

0 comments on commit 26c8687

Please sign in to comment.