Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions proxy/src/main/java/com/velocitypowered/proxy/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,16 @@ static void startMetrics(VelocityServer server, VelocityConfiguration.Metrics me
entry.put(javaVersion, 1);

// http://openjdk.java.net/jeps/223
// Java decided to change their versioning scheme and in doing so modified the
// java.version system property to return $major[.$minor][.$security][-ea], as opposed to
// 1.$major.0_$identifier we can handle pre-9 by checking if the "major" is equal to "1",
// otherwise, 9+
// The java.version system property returns $major[.$minor][.$security][-ea].
String majorVersion = javaVersion.split("\\.")[0];
String release;

int indexOf = javaVersion.lastIndexOf('.');

if (majorVersion.equals("1")) {
release = "Java " + javaVersion.substring(0, indexOf);
} else {
// of course, it really wouldn't be all that simple if they didn't add a quirk, now
// would it valid strings for the major may potentially include values such as -ea to
// denote a pre release
Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion);
if (versionMatcher.find()) {
majorVersion = versionMatcher.group(0);
}
release = "Java " + majorVersion;

// valid strings for the major may potentially include values such as -ea to denote a
// pre-release
Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion);
if (versionMatcher.find()) {
majorVersion = versionMatcher.group(0);
}
String release = "Java " + majorVersion;
map.put(release, entry);

return map;
Expand Down