Skip to content

Commit

Permalink
Loosen option constraint for Java version
Browse files Browse the repository at this point in the history
Later versions of 1.8.0 include options beyond ea. Example:

```
⫸  docker run -t java:8-jdk-alpine java -version
openjdk version "1.8.0_111-internal"
OpenJDK Runtime Environment (build 1.8.0_111-internal-alpine-r0-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)
```
  • Loading branch information
kruppel authored and martint committed Feb 28, 2018
1 parent ed724f3 commit 0aea1c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Expand Up @@ -35,7 +35,7 @@ public class JavaVersion
private static final Pattern PATTERN = Pattern.compile(VERSION_NUMBER + PRE + BUILD + OPT);

// For Java 8 and below
private static final Pattern LEGACY_PATTERN = Pattern.compile("1\\.(?<MAJOR>[0-9]+)(\\.(?<MINOR>(0|[1-9][0-9]*)))?(_(?<UPDATE>[1-9][0-9]*))?(?:-ea)?");
private static final Pattern LEGACY_PATTERN = Pattern.compile("1\\.(?<MAJOR>[0-9]+)(\\.(?<MINOR>(0|[1-9][0-9]*)))?(_(?<UPDATE>[1-9][0-9]*))?" + OPT);

private final int major;
private final int minor;
Expand Down
Expand Up @@ -30,6 +30,7 @@ public void testParseLegacy()
assertEquals(JavaVersion.parse("1.8.0_20"), new JavaVersion(8, 0, OptionalInt.of(20)));
assertEquals(JavaVersion.parse("1.8.1_25"), new JavaVersion(8, 1, OptionalInt.of(25)));
assertEquals(JavaVersion.parse("1.8.0_60-ea"), new JavaVersion(8, 0, OptionalInt.of(60)));
assertEquals(JavaVersion.parse("1.8.0_111-internal"), new JavaVersion(8, 0, OptionalInt.of(111)));
}

@Test
Expand Down

0 comments on commit 0aea1c2

Please sign in to comment.