Skip to content

Commit

Permalink
Merge pull request #41210 from gsmet/java-1.8
Browse files Browse the repository at this point in the history
Avoid NumberFormatException for Java 1.8
  • Loading branch information
gastaldi authored Jun 15, 2024
2 parents c761702 + c41dd13 commit 801260e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ private JavaVersion() {
}

public JavaVersion(String version) {
this.version = version;
if (version != null && version.startsWith("1.")) {
this.version = version.substring(2);
} else {
this.version = version;
}
}

public boolean isEmpty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

class JavaVersionTest {

@Test
public void givenJavaVersion8ShouldReturn8() {
assertEquals(8, new JavaVersion("8").getAsInt());
assertEquals(8, new JavaVersion("1.8").getAsInt());
}

@Test
public void givenJavaVersion17ShouldReturn17() {
assertEquals("17", computeJavaVersion(JAVA, "17"));
Expand Down

0 comments on commit 801260e

Please sign in to comment.