Skip to content

Commit 31bee53

Browse files
committed
Fix the JVM we use for bwc nodes (#46314)
Before this change we would run bwc nodes with their bundled jdk if these supported it, so the passed in runtime JDK was not honored. This became obvius when running with FIPS. Closes #41721
1 parent d5529cb commit 31bee53

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,7 @@ class ClusterFormationTasks {
687687
static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) {
688688
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec ->
689689
exec.workingDir node.cwd
690-
if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes
691-
|| node.nodeVersion.before(Version.fromString("7.0.0"))
692-
|| node.config.distribution == 'integ-test-zip') {
690+
if (useRuntimeJava(project, node)) {
693691
exec.environment.put('JAVA_HOME', project.runtimeJavaHome)
694692
} else {
695693
// force JAVA_HOME to *not* be set
@@ -707,16 +705,20 @@ class ClusterFormationTasks {
707705
}
708706
}
709707

708+
public static boolean useRuntimeJava(Project project, NodeInfo node) {
709+
return (project.isRuntimeJavaHomeSet ||
710+
(node.isBwcNode == false && node.nodeVersion.before(Version.fromString("7.0.0"))) ||
711+
node.config.distribution == 'integ-test-zip')
712+
}
713+
710714
/** Adds a task to start an elasticsearch node with the given configuration */
711715
static Task configureStartTask(String name, Project project, Task setup, NodeInfo node) {
712716
// this closure is converted into ant nodes by groovy's AntBuilder
713717
Closure antRunner = { AntBuilder ant ->
714718
ant.exec(executable: node.executable, spawn: node.config.daemonize, newenvironment: true,
715719
dir: node.cwd, taskname: 'elasticsearch') {
716720
node.env.each { key, value -> env(key: key, value: value) }
717-
if ((project.isRuntimeJavaHomeSet && node.isBwcNode == false) // runtime Java might not be compatible with old nodes
718-
|| node.nodeVersion.before(Version.fromString("7.0.0"))
719-
|| node.config.distribution == 'integ-test-zip') {
721+
if (useRuntimeJava(project, node)) {
720722
env(key: 'JAVA_HOME', value: project.runtimeJavaHome)
721723
}
722724
node.args.each { arg(value: it) }

0 commit comments

Comments
 (0)