Skip to content

Commit

Permalink
use JOSM Utils implementation to allow versions with hypens (i.e. 17-ea)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdenboer authored and mbarrios-simscale committed Apr 16, 2022
1 parent 300cc81 commit c216a49
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/java/tlschannel/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ public static String resultToString(SSLEngineResult result) {
public static int getJavaMajorVersion() {
String version = System.getProperty("java.version");
if (version.startsWith("1.")) {
version = version.substring(2, 3);
} else {
int dot = version.indexOf(".");
if (dot != -1) {
version = version.substring(0, dot);
}
version = version.substring(2);
}
return Integer.parseInt(version);
// Allow these formats:
// 1.8.0_72-ea
// 9-ea
// 9
// 9.0.1
int dotPos = version.indexOf('.');
int dashPos = version.indexOf('-');
return Integer.parseInt(version.substring(0,
dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1));
}
}

0 comments on commit c216a49

Please sign in to comment.