mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-23 05:15:04 +00:00
Handle version parsing in RestClientBuilder (#44737)
Handle version parsing more leniently in RestClientBuilder for the cases where TLS version pinning is required since we cannot use JavaVersion here.
This commit is contained in:
parent
4dd9238cc0
commit
7f6e2aae82
@ -135,19 +135,28 @@ public class RestClientBuilderIntegTests extends RestClientTestCase {
|
||||
*/
|
||||
private static String getProtocol() {
|
||||
String version = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("java.version"));
|
||||
String[] components = version.split("\\.");
|
||||
if (components.length > 0) {
|
||||
final int major = Integer.valueOf(components[0]);
|
||||
String[] parts = version.split("-");
|
||||
String[] numericComponents;
|
||||
if (parts.length == 1) {
|
||||
numericComponents = version.split("\\.");
|
||||
} else if (parts.length == 2) {
|
||||
numericComponents = parts[0].split("\\.");
|
||||
} else {
|
||||
throw new IllegalArgumentException("Java version string [" + version + "] could not be parsed.");
|
||||
}
|
||||
if (numericComponents.length > 0) {
|
||||
final int major = Integer.valueOf(numericComponents[0]);
|
||||
if (major < 11) {
|
||||
return "TLS";
|
||||
} if (major > 12) {
|
||||
}
|
||||
if (major > 12) {
|
||||
return "TLS";
|
||||
} else if (major == 12 && components.length > 2) {
|
||||
final int minor = Integer.valueOf(components[1]);
|
||||
} else if (major == 12 && numericComponents.length > 2) {
|
||||
final int minor = Integer.valueOf(numericComponents[1]);
|
||||
if (minor > 0) {
|
||||
return "TLS";
|
||||
} else {
|
||||
String patch = components[2];
|
||||
String patch = numericComponents[2];
|
||||
final int index = patch.indexOf("_");
|
||||
if (index > -1) {
|
||||
patch = patch.substring(0, index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user