Fix version parsing in various tests (#42871)
This commit fixes the version parsing in various tests. The issue here is that the parsing was relying on java.version. However, java.version can contain additional characters such as -ea for early access builds. See JEP 233: Name Syntax ------------------------------ -------------- java.version $VNUM(\-$PRE)? java.runtime.version $VSTR java.vm.version $VSTR java.specification.version $VNUM java.vm.specification.version $VNUM Instead, we want java.specification.version.
This commit is contained in:
parent
72eb9c2d44
commit
aad1b3a2a0
|
@ -134,7 +134,7 @@ public class RestClientBuilderIntegTests extends RestClientTestCase {
|
|||
* 12.0.1 so we pin to TLSv1.2 when running on an earlier JDK.
|
||||
*/
|
||||
private static String getProtocol() {
|
||||
String version = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("java.version"));
|
||||
String version = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("java.specification.version"));
|
||||
String[] components = version.split("\\.");
|
||||
if (components.length > 0) {
|
||||
final int major = Integer.valueOf(components[0]);
|
||||
|
|
|
@ -281,7 +281,8 @@ public class AzureDiscoveryClusterFormationTests extends ESIntegTestCase {
|
|||
return "TLSv1.2";
|
||||
} else {
|
||||
JavaVersion full =
|
||||
AccessController.doPrivileged((PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.version")));
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.specification.version")));
|
||||
if (full.compareTo(JavaVersion.parse("12.0.1")) < 0) {
|
||||
return "TLSv1.2";
|
||||
}
|
||||
|
|
|
@ -205,7 +205,8 @@ public class HttpExporterSslIT extends MonitoringIntegTestCase {
|
|||
return Collections.singletonList("TLSv1.2");
|
||||
} else {
|
||||
JavaVersion full =
|
||||
AccessController.doPrivileged((PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.version")));
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.specification.version")));
|
||||
if (full.compareTo(JavaVersion.parse("12.0.1")) < 0) {
|
||||
return Collections.singletonList("TLSv1.2");
|
||||
}
|
||||
|
|
|
@ -733,7 +733,8 @@ public class SamlRealmTests extends SamlTestCase {
|
|||
return Collections.singletonList("TLSv1.2");
|
||||
} else {
|
||||
JavaVersion full =
|
||||
AccessController.doPrivileged((PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.version")));
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.specification.version")));
|
||||
if (full.compareTo(JavaVersion.parse("12.0.1")) < 0) {
|
||||
return Collections.singletonList("TLSv1.2");
|
||||
}
|
||||
|
|
|
@ -213,7 +213,8 @@ public class SSLClientAuthTests extends SecurityIntegTestCase {
|
|||
return XPackSettings.DEFAULT_SUPPORTED_PROTOCOLS;
|
||||
}
|
||||
JavaVersion full =
|
||||
AccessController.doPrivileged((PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.version")));
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.specification.version")));
|
||||
if (full.compareTo(JavaVersion.parse("11.0.3")) < 0) {
|
||||
return Collections.singletonList("TLSv1.2");
|
||||
}
|
||||
|
|
|
@ -151,7 +151,8 @@ public class WebhookHttpsIntegrationTests extends AbstractWatcherIntegrationTest
|
|||
return Collections.singletonList("TLSv1.2");
|
||||
} else {
|
||||
JavaVersion full =
|
||||
AccessController.doPrivileged((PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.version")));
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.specification.version")));
|
||||
if (full.compareTo(JavaVersion.parse("12.0.1")) < 0) {
|
||||
return Collections.singletonList("TLSv1.2");
|
||||
}
|
||||
|
|
|
@ -760,7 +760,8 @@ public class HttpClientTests extends ESTestCase {
|
|||
return Collections.singletonList("TLSv1.2");
|
||||
} else {
|
||||
JavaVersion full =
|
||||
AccessController.doPrivileged((PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.version")));
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<JavaVersion>) () -> JavaVersion.parse(System.getProperty("java.specification.version")));
|
||||
if (full.compareTo(JavaVersion.parse("12.0.1")) < 0) {
|
||||
return Collections.singletonList("TLSv1.2");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue