[JAVA-5109] Try creating tests that verify interruptibility of synchronous MongoClient methods and MongoIterable/MongoCursor methods Created: 15/Aug/23  Updated: 07/Sep/23  Resolved: 01/Sep/23

Status: Closed
Project: Java Driver
Component/s: Test Coverage
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Unknown
Reporter: Valentin Kavalenka Assignee: Valentin Kavalenka
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes JAVA-5136 Move the tests from the JAVA_5109 bra... Backlog
Related
is related to JAVA-4876 Update the build to modern Gradle Backlog
Epic Link: Virtual Threads Support
Quarter: FY24Q3
Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Comments   
Comment by Valentin Kavalenka [ 01/Sep/23 ]

Note that the test is not in the master branch: https://github.com/mongodb/mongo-java-driver/tree/JAVA_5109.

Comment by Jeffrey Yemin [ 25/Aug/23 ]

> and I won't continue trying to create tests that we can run as part of our build process, unless the team decides that's what we have to do no matter the cost

Unless ross@mongodb.com can think of a cost-effective way to achieve this, I'm in favor also of a standalone project

Comment by Valentin Kavalenka [ 25/Aug/23 ]

I now will try upgrading to Gradle 7.6. If I succeed, I should be able to use Java SE 19.

While I successfully upgraded to Gradle 7.6, I was unable to set up a new Gradle project with tests that would compile and run only if JDK 19+ is used. This is absolute time waste, and I won't continue trying to create tests that we can run as part of our build process, unless the team decides that's what we have to do no matter the cost (https://github.com/stIncMale/mongo-java-driver/tree/JAVA-5109_add_driver-sync-virtual-threads is what I ended up with).

Instead, I'll create a standalone project with tests that can be run locally, but not on Evergreen. They'll the driver the way other applications use it. At least this way I can make progress.

Comment by Valentin Kavalenka [ 24/Aug/23 ]

Socket IO is interruptible if the socket is associated with a SocketChannel (that's not how we create our sockets, because then we would either have to use SSLEngine explicitly, or via a third-party library) or if the IO is done from a virtual thread. This means that the test has to use virtual threads, i.e., it requires either Java SE 19 (https://openjdk.org/jeps/425) or Java SE 20 (https://openjdk.org/jeps/436).

According to https://docs.gradle.org/current/userguide/compatibility.html#java, using Java SE 19 requires required Gradle 7.6, and using Java SE 20 requires Gradle 8.3.

I tried upgrading Gradle 7.3 to Gradle 8.3, but it is impossible because we use https://plugins.gradle.org/plugin/nebula.optional-base 7.0.0 (the latest at the moment; it allows us to declare optional dependencies without using Gradle feature variants1), which causes Gradle 8.3 to produce

* Where:
Build file '/Users/valentin.kovalenko/Documents/projects/mongo-java-driver/build.gradle' line: 172
 
* What went wrong:
A problem occurred evaluating root project 'mongo-java-driver'.
> org/gradle/api/plugins/MavenPlugin

This error happens because the Gradle plugin with the maven id was removed in 8.0, and the plugin with the maven-publish id must be used instead. This removal was announced in Gradle 7.0, but happened only in Gradle 8.0 without further notifications. Apparently, https://plugins.gradle.org/plugin/nebula.optional-base still uses the maven plugin.

I now will try upgrading to Gradle 7.6. If I succeed, I should be able to use Java SE 19.


1 I tried declaring an optional org.slf4j:slf4j-api dependency using a feature variant instead of nebula.optional-base. Of course, the project did not even evaluate successfully as a result.

Generated at Thu Feb 08 09:03:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.