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
Fix tlschannel.util.Util.getJavaMajorVersion
#969
Conversation
This is a manual cherry-pick and squash of the following commits: - marianobarrios/tls-channel@3b5f8a0 - marianobarrios/tls-channel@f4b780e JAVA-4656
int dotPos = version.indexOf('.'); | ||
int dashPos = version.indexOf('-'); | ||
return Integer.parseInt( | ||
version.substring(0, dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : version.length())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way we deviate here from the algorithm in tls-channel is that instead of using 1
at the end of this line, we use version.length()
. Without this change "17"
is parsed as 1, which then causes class loading issues with the root cause being swallowed and not being present in the logs.
I'll create a PR for tls-channel when this PR is approved.
() -> assertEquals(9, Util.getJavaMajorVersion("9-ea")), | ||
() -> assertEquals(9, Util.getJavaMajorVersion("9")), | ||
() -> assertEquals(9, Util.getJavaMajorVersion("9.0.1")), | ||
() -> assertEquals(17, Util.getJavaMajorVersion("17")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test for a double digit early access, e.g. 19-ea
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Java 8 dies off, everyone will be able to use Runtime.version().feature()
instead of writing his own Util.getJavaMajorVersion
.
Done.
JAVA-4656
This is a combination of a manual cherry-pick and squash of the following commits: - marianobarrios/tls-channel@3b5f8a0 - marianobarrios/tls-channel@f4b780e and a small fix on top of that. JAVA-4656
This is a combination of a manual cherry-pick and squash of the following commits: - marianobarrios/tls-channel@3b5f8a0 - marianobarrios/tls-channel@f4b780e and a small fix on top of that. JAVA-4656
This is a manual cherry-pick and squash of the following commits:
We don't test against JDK 18, and definitely not against early access builds. A manual test confirms that
18-ea
mentioned is the ticket is parsed successfully by the updated code.The ticket does not specify the version the client uses. I am planning to backport the fix only to 4.6.x.
JAVA-4656