File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
client/rest/src/test/java/org/elasticsearch/client Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -135,19 +135,28 @@ private static SSLContext getSslContext() throws Exception {
135
135
*/
136
136
private static String getProtocol () {
137
137
String version = AccessController .doPrivileged ((PrivilegedAction <String >) () -> System .getProperty ("java.version" ));
138
- String [] components = version .split ("\\ ." );
139
- if (components .length > 0 ) {
140
- final int major = Integer .valueOf (components [0 ]);
138
+ String [] parts = version .split ("-" );
139
+ String [] numericComponents ;
140
+ if (parts .length == 1 ) {
141
+ numericComponents = version .split ("\\ ." );
142
+ } else if (parts .length == 2 ) {
143
+ numericComponents = parts [0 ].split ("\\ ." );
144
+ } else {
145
+ throw new IllegalArgumentException ("Java version string [" + version + "] could not be parsed." );
146
+ }
147
+ if (numericComponents .length > 0 ) {
148
+ final int major = Integer .valueOf (numericComponents [0 ]);
141
149
if (major < 11 ) {
142
150
return "TLS" ;
143
- } if (major > 12 ) {
151
+ }
152
+ if (major > 12 ) {
144
153
return "TLS" ;
145
- } else if (major == 12 && components .length > 2 ) {
146
- final int minor = Integer .valueOf (components [1 ]);
154
+ } else if (major == 12 && numericComponents .length > 2 ) {
155
+ final int minor = Integer .valueOf (numericComponents [1 ]);
147
156
if (minor > 0 ) {
148
157
return "TLS" ;
149
158
} else {
150
- String patch = components [2 ];
159
+ String patch = numericComponents [2 ];
151
160
final int index = patch .indexOf ("_" );
152
161
if (index > -1 ) {
153
162
patch = patch .substring (0 , index );
You can’t perform that action at this time.
0 commit comments