Skip to content
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

Merged
merged 3 commits into from Jun 23, 2022

Conversation

stIncMale
Copy link
Member

@stIncMale stIncMale commented Jun 22, 2022

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

This is a manual cherry-pick and squash of the following commits:
- marianobarrios/tls-channel@3b5f8a0
- marianobarrios/tls-channel@f4b780e

JAVA-4656
@stIncMale stIncMale requested a review from jyemin June 22, 2022 07:39
@stIncMale stIncMale self-assigned this Jun 22, 2022
@stIncMale stIncMale requested review from katcharov and jyemin and removed request for jyemin June 22, 2022 07:41
JAVA-4656
int dotPos = version.indexOf('.');
int dashPos = version.indexOf('-');
return Integer.parseInt(
version.substring(0, dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : version.length()));
Copy link
Member Author

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.

@stIncMale stIncMale requested a review from rozza June 23, 2022 03:01
() -> assertEquals(9, Util.getJavaMajorVersion("9-ea")),
() -> assertEquals(9, Util.getJavaMajorVersion("9")),
() -> assertEquals(9, Util.getJavaMajorVersion("9.0.1")),
() -> assertEquals(17, Util.getJavaMajorVersion("17")),
Copy link
Contributor

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?

Copy link
Member Author

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.

@stIncMale stIncMale merged commit 1375eee into mongodb:master Jun 23, 2022
@stIncMale stIncMale deleted the JAVA-4656 branch June 23, 2022 15:36
stIncMale added a commit that referenced this pull request Jun 23, 2022
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
ispringer pushed a commit to evergage/mongo-java-driver that referenced this pull request May 16, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants