-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Test on Java 21 #1326
Test on Java 21 #1326
Conversation
25961ac
to
b03aadd
Compare
// If the Java 11+ extended socket options for keep alive probes are available, check those values. | ||
if (Arrays.stream(ExtendedSocketOptions.getDeclaredFields()).anyMatch{ f -> f.getName().equals('TCP_KEEPCOUNT') }) { | ||
Method getOptionMethod = Socket.getMethod('getOption', SocketOption) | ||
getOptionMethod.invoke(socket, ExtendedSocketOptions.getDeclaredField('TCP_KEEPCOUNT').get(null)) == 9 | ||
getOptionMethod.invoke(socket, ExtendedSocketOptions.getDeclaredField('TCP_KEEPIDLE').get(null)) == 120 | ||
getOptionMethod.invoke(socket, ExtendedSocketOptions.getDeclaredField('TCP_KEEPINTERVAL').get(null)) == 10 | ||
Method getOptionMethod | ||
try { | ||
getOptionMethod = Socket.getMethod('getOption', SocketOption) | ||
} catch (NoSuchMethodException e) { | ||
// ignore, the `Socket.getOption` method was added in Java SE 9 and does not exist in Java SE 8 | ||
getOptionMethod = null | ||
} |
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.
This code assumed that if ExtendedSocketOptions.TCP_KEEPCOUNT
is available, then so is Socket.getOption
. That's not actually the case:
ExtendedSocketOptions.TCP_KEEPCOUNT
(not part of the Java SE) was added in Oracle JDK 81 (this is not part of the Java SE API, so it does not have to be in all JDKs): https://docs.oracle.com/javase/8/docs/jre/api/net/socketoptions/spec/jdk/net/ExtendedSocketOptions.html#TCP_KEEPCOUNTSocket.getOption
was added in the Java SE 9.- So when I run
sdk use java 17.0.10-librca && ./gradlew -PjavaVersion=8 clean :driver-core:test
locally,ExtendedSocketOptions.TCP_KEEPCOUNT
is present, whileSocket.getOption
is not, which leads to a failure. - Why is this not a problem in Evergreen? My guess is that the JDK 8 it uses does not have
ExtendedSocketOptions.TCP_KEEPCOUNT
.
1 Currently, Oracle mistakenly documents it as added in JDK 11, see https://docs.oracle.com/en/java/javase/21/docs/api/jdk.net/jdk/net/ExtendedSocketOptions.html#TCP_KEEPCOUNT.
@@ -29,7 +29,7 @@ object TestMongoClientHelper { | |||
|
|||
val mongoClientURI: String = { | |||
val uri = Properties.propOrElse(MONGODB_URI_SYSTEM_PROPERTY_NAME, DEFAULT_URI) | |||
if (!uri.isBlank) uri else DEFAULT_URI | |||
if (!uri.codePoints().allMatch((cp: Int) => Character.isWhitespace(cp))) uri else DEFAULT_URI |
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.
String.isBlank
was added in Java SE 11, so when I run sdk use java 17.0.10-librca && ./gradlew -PjavaVersion=8 clean :driver-scala:integrationTest
locally, it fails.
The are two reasons this hasn't been a problem in Evergreen:
run-tests.sh
did not run theintegrationTest
task (thetest
task does not depend onintegrationTest
). Update: I still does not run theintegrationTest
task because I rolled the related change back: the tests weren't running correctly when run byrun-tests.sh
, and on top of that @jyemin suggested to roll the change back.run-scala-tests.sh
did not useJAVA_VERSION
. So, despite this script runningintegrationTest
implicitly, it was using the same JDK Gradle is run by.
* Add JDK 21 to Gradle configuration * Add JDK 21 to the test matrix * Replace JDK 17 with JDK 21 for tasks that are ony run using latest JDK * Update dependencies (some now have to be conditional) * Update `run-scala-tests.sh` to use `JAVA_VERSION` * Run the `scala-tests` task with JDK 8, 17, 21 similarly to `kotlin-tests` * Update `run-tests.sh` to run the `integrationTest` task (some Scala tests, like `ClientSideEncryptionBypassAutoEncryptionSpec` were not run by it) * Fix test code that assumed Java SE 9+ JAVA-5164 --------- Co-authored-by: Jeff Yemin <[email protected]>
JAVA-5164
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.
LGTM
@@ -2037,7 +2041,8 @@ buildvariants: | |||
- name: "test" | |||
|
|||
- matrix_name: "tests-jdk-secure" | |||
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17" ], version: [ "3.6", "4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "latest" ], | |||
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17", "jdk21"], |
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.
As part of MongoDBs green sustainability drive we should review how much resources the matrix takes up and if we can keep coverage without duplicating testing. I'll open a ticket.
This PR builds up on #1242.
run-scala-tests.sh
to useJAVA_VERSION
scala-tests
task with JDK 8, 17, 21 similarly tokotlin-tests
JAVA-5164