Skip to content

Commit 841fe17

Browse files
breskebyelasticsearchmachine
andauthored
[8.18] [CI] Handle git snapshot BWC versions correctly when calculating jdk fallback (#135399) (#135412)
* [CI] Handle git snapshot BWC versions correctly when calculating jdk fallback (#135399) In #135300 we introduced a fallback to use adoptopenjdk17 when running bwc tests with older distributions. This fix handles the calculation of overriding requirement by taken 0.0.0 version into account which is used to represent versions representing git snapshots. (cherry picked from commit 6047a74) # Conflicts: # build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java # test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java * [CI] Auto commit changes from spotless * Fix typo --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent ef50c3e commit 841fe17

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/util/OsUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private OsUtils() {}
3838
* This method returns true if the given version of the JDK is known to be incompatible
3939
*/
4040
public static boolean jdkIsIncompatibleWithOS(Version version) {
41-
return version.onOrBefore("8.10.4") && isUbuntu2404OrLater();
41+
return version.after("0.0.0") && version.onOrBefore("8.10.4") && isUbuntu2404OrLater();
4242
}
4343

4444
private static boolean isUbuntu2404OrLater() {

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public abstract class AbstractLocalClusterFactory<S extends LocalClusterSpec, H
8282
private static final String ENABLE_DEBUG_JVM_ARGS = "-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=";
8383
private static final String ENTITLEMENT_POLICY_YAML = "entitlement-policy.yaml";
8484
private static final String PLUGIN_DESCRIPTOR_PROPERTIES = "plugin-descriptor.properties";
85-
public static final String DISTRO_WITH_JDK_LOWER_21 = "8.11.0";
85+
public static final String FIRST_DISTRO_WITH_JDK_21 = "8.11.0";
8686

8787
private final DistributionResolver distributionResolver;
8888

@@ -864,7 +864,7 @@ private void startElasticsearch() {
864864
private Map<String, String> getEnvironmentVariables() {
865865
Map<String, String> environment = new HashMap<>(spec.resolveEnvironment());
866866
String esFallbackJavaHome = System.getenv("ES_FALLBACK_JAVA_HOME");
867-
if (spec.getVersion().before(DISTRO_WITH_JDK_LOWER_21) && esFallbackJavaHome != null && esFallbackJavaHome.isEmpty() == false) {
867+
if (jdkIsIncompatible(spec.getVersion()) && esFallbackJavaHome != null && esFallbackJavaHome.isEmpty() == false) {
868868
environment.put("ES_JAVA_HOME", esFallbackJavaHome);
869869
}
870870
environment.put("ES_PATH_CONF", configDir.toString());
@@ -928,6 +928,10 @@ private Map<String, String> getJvmOptionsReplacements() {
928928
);
929929
}
930930

931+
private boolean jdkIsIncompatible(Version version) {
932+
return version.after("0.0.0") && version.before(FIRST_DISTRO_WITH_JDK_21);
933+
}
934+
931935
private void runToolScript(String tool, String input, String... args) {
932936
try {
933937
int exit = ProcessUtils.exec(

0 commit comments

Comments
 (0)