Skip to content

Commit

Permalink
Simplify Java version logic
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Aug 14, 2023
1 parent ecabef3 commit 331d924
Showing 1 changed file with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,8 @@ public abstract class DockerComputerConnectorTest {
protected static final String INSTANCE_CAP = "10";

private static int getJavaVersion() {
final String systemPropertyName = "java.version";
final String javaVersion = System.getProperty(systemPropertyName);
try {
// We're using Java 9 or higher so the syntax is x.n...
// ... but x might be multiple digits.
// e.g. 9.0 is Java 9, 11.123.4 is Java 11 etc.
// Early access builds report as "21-ea". Remove all text after "-".
final int indexOfPeriod = javaVersion.indexOf('.');
final String firstNumber = javaVersion.replaceAll("[-.].*", "");
return Integer.parseInt(firstNumber);
} catch (RuntimeException ex) {
throw new IllegalStateException(
"Unable to determine version of Java from system property '" + systemPropertyName + "' value '"
+ javaVersion + "'.",
ex);
}
Runtime.Version runtimeVersion = Runtime.version();
return runtimeVersion.version().get(0);
}

protected static String getJenkinsDockerImageVersionForThisEnvironment() {
Expand Down

0 comments on commit 331d924

Please sign in to comment.