Skip to content

Allow parsing the value of java.version sysprop #44017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2019

Conversation

jkakavas
Copy link
Member

@jkakavas jkakavas commented Jul 5, 2019

We often start testing with early access versions of new Java
versions and this have caused minor issues in our tests
(i.e. #43141) because the version string that the JVM reports
cannot be parsed as it ends with the string -ea.

This commit changes how we parse and compare Java versions to
allow correct parsing and comparison of the output of java.version
system property that might include an additional alphanumeric
part after the version numbers (see [JEP 223[(https://openjdk.java.net/jeps/223)).

It also changes a number of tests that would attempt to parse
java.specification.version in order to get the full version
of Java. java.specification.version only contains the major
version and is thus inappropriate when trying to compare against
a version that might contain a minor, patch or an early access
part. We know parse java.version that can be consistently
parsed.

Resolves #43141

We often start testing with early access versions of new Java
versions and this have caused minor issues in our tests
(i.e. elastic#43141) because the version string that the JVM reports
cannot be parsed as it ends with the string `-ea`.

This commit changes how we parse and compare Java versions to
allow correct parsing of early access versions. Early access
versions of the same exact Java version are considered, well,
earlier when comparing.

It also changes a number of tests that would attempt to parse
`java.specification.version` in order to get the full version
of Java. `java.specification.version` only contains the major
version and is thus inappropriate when trying to compare against
a version that might contain a minor, patch or an early access
part. We know parse `java.version` that can be consistently
parsed.
@jkakavas jkakavas added >non-issue :Core/Infra/Core Core issues without another label v8.0.0 v7.4.0 labels Jul 5, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jkakavas
Copy link
Member Author

jkakavas commented Jul 5, 2019

@elasticmachine update branch

@jkakavas jkakavas requested a review from jakelandis July 8, 2019 13:35
@davidkyle
Copy link
Member

@jkakavas if this fixes #43141 please backport all the way to 7.3 as SslMultiPortTests are also failing there

@jkakavas
Copy link
Member Author

jkakavas commented Jul 8, 2019

@jkakavas if this fixes #43141 please backport all the way to 7.3 as SslMultiPortTests are also failing there

It does, if es-core-infra likes this approach, I'll backport this to 7.3 too , otherwise I'll come up with a solution to handle the tests only

@jakelandis jakelandis requested review from rjernst and removed request for jakelandis July 9, 2019 15:30
@rjernst
Copy link
Member

rjernst commented Jul 9, 2019

Thanks for looking into this @jkakavas!

While I understand the need to handle -ea in parsing, I don't think we should treat EA version as special, in that we should not have the isEarlyAccess() flag. Long term, we should be using Runtime.Version, which is provided as part of the JDK. The portion of the version specification that allows -ea can have other things, it is the "$PRE" portion of $VNUM(-$PRE)?\+$BUILD(-$OPT)? in JEP 322.

The difference here with what you have implemented is we shouldn't try to discern any meaning out of $PRE. The specification allows it to be any alphanum string. For comparison logic, the javadocs state:

A version with a pre-release identifier is always considered to be less than a version without one. Pre-release identifiers are compared numerically when they consist only of digits, and lexicographically otherwise

So, I think we can get the same behavior you are after, but without having any "-ea" special string or comparison.

@jkakavas
Copy link
Member Author

jkakavas commented Jul 9, 2019

Got it , makes sense @rjernst. I didn't meant to attach any special meaning to the early access flag, isEarlyAccess() was just a utility method for the comparison part. I'll address this to make the comparison generic as dictated in JEP-322 and keep an eye for this to move to Runtime.Version when java 8 won't be supported.

This commit changes the behavior to enable more generic parsing of
the value of java.version system property as this is described in
https://openjdk.java.net/jeps/223. In short it handles a version
number part, like before, but additionally a PRE part that matches
([a-zA-Z0-9]+).
@jkakavas
Copy link
Member Author

jkakavas commented Jul 9, 2019

Changed this to be able to handle the value of java.version ($VNUM(\-$PRE)?) and java.specification.version ($VNUM) as these are the use cases we currently have. In order to support fully parsing java.runtime.version , we'd have to replicate much of Runtime.Version logic and there currently doesn't seem to be a reason to do so.

@jkakavas jkakavas changed the title Handle early access versions in JavaVersion Allow parsing the value of java.version sysprop Jul 9, 2019
@jkakavas
Copy link
Member Author

No rush, just pinging for visibility @rjernst.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

numericComponents = parts[0].split("\\.");
prePart = parts[1];
} else {
throw new IllegalArgumentException("value");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a more descriptive failure message, which includes the actual value, not the literal string value. ;)

@jkakavas
Copy link
Member Author

@rjernst This wouldn't normally go into a patch release (7.3.1) but it does resolve the CI issues we see in 7.3 (#43141) so I'm thinking I'd backport this to 7.3 too. Objections ?

@jkakavas
Copy link
Member Author

Both ci/1 and ci/2 have completed successfully but the notification failed to reach :octocat: because of the service hiccups.

18:53:20 Could not update commit status of the Pull Request on GitHub.
18:53:20 org.kohsuke.github.HttpException: Server returned HTTP response code: 500, message: 'Internal Server Error' for URL: https://api.github.com/repos/elastic/elasticsearch/statuses/...

ci/1: https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+pull-request-1/3323/console
ci/2 : https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+pull-request-2/3302/console

@jkakavas jkakavas merged commit 3b7b025 into elastic:master Jul 22, 2019
jkakavas added a commit that referenced this pull request Jul 22, 2019
We often start testing with early access versions of new Java
versions and this have caused minor issues in our tests
(i.e. #43141) because the version string that the JVM reports
cannot be parsed as it ends with the string -ea.

This commit changes how we parse and compare Java versions to
allow correct parsing and comparison of the output of java.version
system property that might include an additional alphanumeric
part after the version numbers
 (see [JEP 223[(https://openjdk.java.net/jeps/223)). In short it 
handles a version number part, like before, but additionally a 
PRE part that matches ([a-zA-Z0-9]+).

It also changes a number of tests that would attempt to parse
java.specification.version in order to get the full version
of Java. java.specification.version only contains the major
version and is thus inappropriate when trying to compare against
a version that might contain a minor, patch or an early access
part. We know parse java.version that can be consistently
parsed.

Resolves #43141
jkakavas added a commit that referenced this pull request Jul 23, 2019
We often start testing with early access versions of new Java
versions and this have caused minor issues in our tests
(i.e. #43141) because the version string that the JVM reports
cannot be parsed as it ends with the string -ea.

This commit changes how we parse and compare Java versions to
allow correct parsing and comparison of the output of java.version
system property that might include an additional alphanumeric
part after the version numbers
 (see [JEP 223[(https://openjdk.java.net/jeps/223)). In short it 
handles a version number part, like before, but additionally a 
PRE part that matches ([a-zA-Z0-9]+).

It also changes a number of tests that would attempt to parse
java.specification.version in order to get the full version
of Java. java.specification.version only contains the major
version and is thus inappropriate when trying to compare against
a version that might contain a minor, patch or an early access
part. We know parse java.version that can be consistently
parsed.

Resolves #43141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TEST] SslMultiPortTests failing on 7.x
5 participants