Skip to content

Commit 719572a

Browse files
committed
Merge branch 'main' into JAVA-4586_bulk-write
2 parents b0e2bdf + 1b6f13a commit 719572a

File tree

235 files changed

+10489
-2640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+10489
-2640
lines changed

.evergreen/.evg.yml

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ functions:
144144

145145
"create and upload SSDLC release assets":
146146
- command: shell.exec
147-
shell: "bash"
148147
params:
148+
shell: "bash"
149149
working_dir: "src"
150150
env:
151151
PRODUCT_NAME: ${product_name}
@@ -287,7 +287,7 @@ functions:
287287
288288
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" \
289289
COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
290-
.evergreen/run-tests.sh
290+
TESTS="${TESTS}" .evergreen/run-tests.sh
291291
292292
"run load-balancer tests":
293293
- command: shell.exec
@@ -335,7 +335,7 @@ functions:
335335
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" COMPRESSOR="${COMPRESSOR}" \
336336
JAVA_VERSION="${JAVA_VERSION}" \
337337
AZUREKMS_KEY_VAULT_ENDPOINT=${testazurekms_keyvaultendpoint} AZUREKMS_KEY_NAME=${testazurekms_keyname} \
338-
SLOW_TESTS_ONLY=true .evergreen/run-tests.sh
338+
TESTS="testSlowOnly" .evergreen/run-tests.sh
339339
340340
"run scala tests":
341341
- command: shell.exec
@@ -861,11 +861,42 @@ tasks:
861861
vars:
862862
file: ".evergreen/static-checks.sh"
863863

864-
- name: "test"
864+
- name: "test-bson-and-crypt"
865+
commands:
866+
- func: "run tests"
867+
vars:
868+
TESTS: 'bson:test bson-record-codec:test mongodb-crypt:test'
869+
870+
- name: "test-core"
871+
commands:
872+
- func: "bootstrap mongo-orchestration"
873+
- func: "run tests"
874+
vars:
875+
TESTS: 'driver-core:test'
876+
877+
- name: "test-legacy"
865878
commands:
866879
- func: "start-kms-kmip-server"
867880
- func: "bootstrap mongo-orchestration"
868881
- func: "run tests"
882+
vars:
883+
TESTS: 'driver-legacy:test'
884+
885+
- name: "test-sync"
886+
commands:
887+
- func: "start-kms-kmip-server"
888+
- func: "bootstrap mongo-orchestration"
889+
- func: "run tests"
890+
vars:
891+
TESTS: 'driver-sync:test'
892+
893+
- name: "test-reactive"
894+
commands:
895+
- func: "start-kms-kmip-server"
896+
- func: "bootstrap mongo-orchestration"
897+
- func: "run tests"
898+
vars:
899+
TESTS: 'driver-reactive-streams:test'
869900

870901
- name: load-balancer-test
871902
commands:
@@ -1826,11 +1857,11 @@ axes:
18261857
- id: "2.12"
18271858
display_name: "Scala 2.12"
18281859
variables:
1829-
SCALA: "2.12.15"
1860+
SCALA: "2.12.20"
18301861
- id: "2.13"
18311862
display_name: "Scala 2.13"
18321863
variables:
1833-
SCALA: "2.13.6"
1864+
SCALA: "2.13.15"
18341865

18351866
# Choice of MongoDB storage engine
18361867
- id: storage-engine
@@ -2105,14 +2136,20 @@ buildvariants:
21052136
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21062137
tags: ["tests-variant"]
21072138
tasks:
2108-
- name: "test"
2139+
- name: "test-sync"
2140+
- name: "test-reactive"
2141+
- name: "test-core"
2142+
- name: "test-legacy"
21092143

21102144
- matrix_name: "tests-snappy-compression"
21112145
matrix_spec: { compressor : "snappy", auth: "noauth", ssl: "nossl", jdk: "jdk8", version: "*", topology: "standalone", os: "linux" }
21122146
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21132147
tags: ["tests-variant"]
21142148
tasks:
2115-
- name: "test"
2149+
- name: "test-sync"
2150+
- name: "test-reactive"
2151+
- name: "test-core"
2152+
- name: "test-legacy"
21162153

21172154
- matrix_name: "tests-zstd-compression"
21182155
matrix_spec: { compressor : "zstd", auth: "noauth", ssl: "nossl", jdk: "jdk8",
@@ -2121,15 +2158,28 @@ buildvariants:
21212158
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21222159
tags: ["tests-variant"]
21232160
tasks:
2124-
- name: "test"
2161+
- name: "test-sync"
2162+
- name: "test-reactive"
2163+
- name: "test-core"
2164+
- name: "test-legacy"
2165+
2166+
- matrix_name: "tests-unit"
2167+
matrix_spec: { jdk: [ "jdk8", "jdk11", "jdk17", "jdk21"], os: "linux" }
2168+
display_name: "${jdk} ${os} Unit"
2169+
tags: ["tests-variant"]
2170+
tasks:
2171+
- name: "test-bson-and-crypt"
21252172

21262173
- matrix_name: "tests-jdk8-unsecure"
21272174
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
21282175
topology: "*", os: "linux" }
21292176
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21302177
tags: ["tests-variant"]
21312178
tasks:
2132-
- name: "test"
2179+
- name: "test-sync"
2180+
- name: "test-reactive"
2181+
- name: "test-core"
2182+
- name: "test-legacy"
21332183

21342184
- matrix_name: "tests-jdk-secure"
21352185
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17", "jdk21"],
@@ -2138,22 +2188,31 @@ buildvariants:
21382188
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21392189
tags: ["tests-variant"]
21402190
tasks:
2141-
- name: "test"
2191+
- name: "test-sync"
2192+
- name: "test-reactive"
2193+
- name: "test-core"
2194+
- name: "test-legacy"
21422195

21432196
- matrix_name: "tests-jdk-secure-jdk11"
21442197
matrix_spec: { auth: "auth", ssl: "ssl", jdk: ["jdk11"], version: ["7.0"], topology: ["replicaset"], os: "linux" }
21452198
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
21462199
tags: ["tests-variant"]
21472200
tasks:
2148-
- name: "test"
2201+
- name: "test-sync"
2202+
- name: "test-reactive"
2203+
- name: "test-core"
2204+
- name: "test-legacy"
21492205

21502206
- matrix_name: "tests-require-api-version"
21512207
matrix_spec: { api-version: "required", auth: "auth", ssl: "nossl", jdk: ["jdk21"], version: ["5.0", "6.0", "7.0", "8.0", "latest"],
21522208
topology: "standalone", os: "linux" }
21532209
display_name: "${version} ${topology} ${api-version} "
21542210
tags: ["tests-variant"]
21552211
tasks:
2156-
- name: "test"
2212+
- name: "test-sync"
2213+
- name: "test-reactive"
2214+
- name: "test-core"
2215+
- name: "test-legacy"
21572216

21582217
- matrix_name: "tests-load-balancer-secure"
21592218
matrix_spec: { auth: "auth", ssl: "ssl", jdk: ["jdk21"], version: ["5.0", "6.0", "7.0", "8.0", "latest"], topology: "sharded-cluster",

.evergreen/run-atlas-search-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ echo "Running Atlas Search tests"
1616
./gradlew --stacktrace --info \
1717
-Dorg.mongodb.test.atlas.search=true \
1818
-Dorg.mongodb.test.uri=${MONGODB_URI} \
19-
driver-core:test --tests AggregatesSearchIntegrationTest
19+
driver-core:test --tests AggregatesSearchIntegrationTest --tests AggregatesVectorSearchIntegrationTest

.evergreen/run-graalvm-native-image-app.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ echo "The Gradle version is"
2222
./gradlew --version
2323

2424
echo "Building and running the GraalVM native image app"
25-
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} :graalvm-native-image-app:nativeRun
25+
./gradlew -PincludeGraalvm -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} :graalvm-native-image-app:nativeRun

.evergreen/run-tests.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ MONGODB_URI=${MONGODB_URI:-}
3535
TOPOLOGY=${TOPOLOGY:-server}
3636
COMPRESSOR=${COMPRESSOR:-}
3737
STREAM_TYPE=${STREAM_TYPE:-nio2}
38+
TESTS=${TESTS:-test}
3839
SLOW_TESTS_ONLY=${SLOW_TESTS_ONLY:-false}
3940

4041
export ASYNC_TYPE="-Dorg.mongodb.test.async.type=${STREAM_TYPE}"
@@ -136,15 +137,8 @@ echo "Running $AUTH tests over $SSL for $TOPOLOGY and connecting to $MONGODB_URI
136137
echo "Running tests with Java ${JAVA_VERSION}"
137138
./gradlew -version
138139

139-
if [ "$SLOW_TESTS_ONLY" == "true" ]; then
140-
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
141-
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
142-
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
143-
--stacktrace --info testSlowOnly
144-
else
145-
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
146-
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
147-
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
148-
-Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled=true \
149-
--stacktrace --info --continue test
150-
fi
140+
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \
141+
${MULTI_MONGOS_URI_SYSTEM_PROPERTY} ${API_VERSION} ${GRADLE_EXTRA_VARS} ${ASYNC_TYPE} \
142+
${JAVA_SYSPROP_NETTY_SSL_PROVIDER} \
143+
-Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled=true \
144+
--stacktrace --info --continue ${TESTS}

.evergreen/ssdlc-report.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ declare -r EVERGREEN_BUILD_URL_PREFIX="https://spruce.mongodb.com/version"
4040
declare -r GIT_TAG="r${PRODUCT_VERSION}"
4141
GIT_COMMIT_HASH="$(git rev-list --ignore-missing -n 1 "${GIT_TAG}")"
4242
set +e
43-
GIT_BRANCH_MASTER="$(git branch -a --contains "${GIT_TAG}" | grep 'master$')"
43+
GIT_BRANCH_DEFAULT="$(git branch -a --contains "${GIT_TAG}" | grep 'main$')"
4444
GIT_BRANCH_PATCH="$(git branch -a --contains "${GIT_TAG}" | grep '\.x$')"
4545
set -e
46-
if [ -n "${GIT_BRANCH_MASTER}" ]; then
46+
if [ -n "${GIT_BRANCH_DEFAULT}" ]; then
4747
declare -r EVERGREEN_BUILD_URL="${EVERGREEN_BUILD_URL_PREFIX}/${EVERGREEN_PROJECT_NAME_PREFIX}_${GIT_COMMIT_HASH}"
4848
elif [ -n "${GIT_BRANCH_PATCH}" ]; then
4949
# strip out the patch version

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ jobs:
7878
exit 1
7979
8080
# For non-patch releases (A.B.C where C == 0), we expect the release to
81-
# be triggered from master or the A.B.x maintenance branch. This includes
81+
# be triggered from main or the A.B.x maintenance branch. This includes
8282
# pre-releases for any non-patch releases, e.g. 5.2.0-beta1
8383
- name: "Fail if non-patch release is created from wrong release branch"
84-
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_SUFFIX, '.0') && env.RELEASE_BRANCH != github.ref_name && github.ref_name != 'master' }}
84+
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_SUFFIX, '.0') && env.RELEASE_BRANCH != github.ref_name && github.ref_name != 'main' }}
8585
run: |
86-
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }} or master, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
86+
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }} or main, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
8787
exit 1
8888
8989
# Set commit author information to the user that triggered the release workflow

bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/BsonDecoder.kt

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ import org.bson.BsonType
3737
import org.bson.BsonValue
3838
import org.bson.codecs.BsonValueCodec
3939
import org.bson.codecs.DecoderContext
40-
import org.bson.codecs.kotlinx.BsonDecoder.Companion.createBsonArrayDecoder
41-
import org.bson.codecs.kotlinx.BsonDecoder.Companion.createBsonDocumentDecoder
42-
import org.bson.codecs.kotlinx.BsonDecoder.Companion.createBsonMapDecoder
43-
import org.bson.codecs.kotlinx.BsonDecoder.Companion.createBsonPolymorphicDecoder
40+
import org.bson.codecs.kotlinx.utils.BsonCodecUtils.createBsonArrayDecoder
41+
import org.bson.codecs.kotlinx.utils.BsonCodecUtils.createBsonDecoder
42+
import org.bson.codecs.kotlinx.utils.BsonCodecUtils.createBsonDocumentDecoder
43+
import org.bson.codecs.kotlinx.utils.BsonCodecUtils.createBsonMapDecoder
44+
import org.bson.codecs.kotlinx.utils.BsonCodecUtils.createBsonPolymorphicDecoder
4445
import org.bson.internal.NumberCodecHelper
4546
import org.bson.internal.StringCodecHelper
4647
import org.bson.types.ObjectId
@@ -51,75 +52,12 @@ import org.bson.types.ObjectId
5152
* For custom serialization handlers
5253
*/
5354
@ExperimentalSerializationApi
54-
internal sealed interface BsonDecoder : Decoder, CompositeDecoder {
55-
56-
/** Factory helper for creating concrete BsonDecoder implementations */
57-
companion object {
58-
59-
@Suppress("SwallowedException")
60-
private val hasJsonDecoder: Boolean by lazy {
61-
try {
62-
Class.forName("kotlinx.serialization.json.JsonDecoder")
63-
true
64-
} catch (e: ClassNotFoundException) {
65-
false
66-
}
67-
}
68-
69-
fun createBsonDecoder(
70-
reader: AbstractBsonReader,
71-
serializersModule: SerializersModule,
72-
configuration: BsonConfiguration
73-
): BsonDecoder {
74-
return if (hasJsonDecoder) JsonBsonDecoderImpl(reader, serializersModule, configuration)
75-
else BsonDecoderImpl(reader, serializersModule, configuration)
76-
}
77-
78-
fun createBsonArrayDecoder(
79-
descriptor: SerialDescriptor,
80-
reader: AbstractBsonReader,
81-
serializersModule: SerializersModule,
82-
configuration: BsonConfiguration
83-
): BsonArrayDecoder {
84-
return if (hasJsonDecoder) JsonBsonArrayDecoder(descriptor, reader, serializersModule, configuration)
85-
else BsonArrayDecoder(descriptor, reader, serializersModule, configuration)
86-
}
87-
88-
fun createBsonDocumentDecoder(
89-
descriptor: SerialDescriptor,
90-
reader: AbstractBsonReader,
91-
serializersModule: SerializersModule,
92-
configuration: BsonConfiguration
93-
): BsonDocumentDecoder {
94-
return if (hasJsonDecoder) JsonBsonDocumentDecoder(descriptor, reader, serializersModule, configuration)
95-
else BsonDocumentDecoder(descriptor, reader, serializersModule, configuration)
96-
}
97-
98-
fun createBsonPolymorphicDecoder(
99-
descriptor: SerialDescriptor,
100-
reader: AbstractBsonReader,
101-
serializersModule: SerializersModule,
102-
configuration: BsonConfiguration
103-
): BsonPolymorphicDecoder {
104-
return if (hasJsonDecoder) JsonBsonPolymorphicDecoder(descriptor, reader, serializersModule, configuration)
105-
else BsonPolymorphicDecoder(descriptor, reader, serializersModule, configuration)
106-
}
107-
108-
fun createBsonMapDecoder(
109-
descriptor: SerialDescriptor,
110-
reader: AbstractBsonReader,
111-
serializersModule: SerializersModule,
112-
configuration: BsonConfiguration
113-
): BsonMapDecoder {
114-
return if (hasJsonDecoder) JsonBsonMapDecoder(descriptor, reader, serializersModule, configuration)
115-
else BsonMapDecoder(descriptor, reader, serializersModule, configuration)
116-
}
117-
}
55+
public sealed interface BsonDecoder : Decoder, CompositeDecoder {
11856

11957
/** @return the decoded ObjectId */
120-
fun decodeObjectId(): ObjectId
58+
public fun decodeObjectId(): ObjectId
12159
/** @return the decoded BsonValue */
122-
fun decodeBsonValue(): BsonValue
60+
public fun decodeBsonValue(): BsonValue
12361
}
12462

12563
@OptIn(ExperimentalSerializationApi::class)
@@ -325,7 +263,7 @@ internal open class BsonPolymorphicDecoder(
325263
it.reset()
326264
mark = null
327265
}
328-
return deserializer.deserialize(BsonDecoder.createBsonDecoder(reader, serializersModule, configuration))
266+
return deserializer.deserialize(createBsonDecoder(reader, serializersModule, configuration))
329267
}
330268

331269
override fun decodeElementIndex(descriptor: SerialDescriptor): Int {

bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/BsonEncoder.kt

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,21 @@ import org.bson.types.ObjectId
3939
* For custom serialization handlers
4040
*/
4141
@ExperimentalSerializationApi
42-
internal sealed interface BsonEncoder : Encoder, CompositeEncoder {
43-
44-
/** Factory helper for creating concrete BsonEncoder implementations */
45-
companion object {
46-
@Suppress("SwallowedException")
47-
private val hasJsonEncoder: Boolean by lazy {
48-
try {
49-
Class.forName("kotlinx.serialization.json.JsonEncoder")
50-
true
51-
} catch (e: ClassNotFoundException) {
52-
false
53-
}
54-
}
55-
56-
fun createBsonEncoder(
57-
writer: BsonWriter,
58-
serializersModule: SerializersModule,
59-
configuration: BsonConfiguration
60-
): BsonEncoder {
61-
return if (hasJsonEncoder) JsonBsonEncoder(writer, serializersModule, configuration)
62-
else BsonEncoderImpl(writer, serializersModule, configuration)
63-
}
64-
}
42+
public sealed interface BsonEncoder : Encoder, CompositeEncoder {
6543

6644
/**
6745
* Encodes an ObjectId
6846
*
6947
* @param value the ObjectId
7048
*/
71-
fun encodeObjectId(value: ObjectId)
49+
public fun encodeObjectId(value: ObjectId)
7250

7351
/**
7452
* Encodes a BsonValue
7553
*
7654
* @param value the BsonValue
7755
*/
78-
fun encodeBsonValue(value: BsonValue)
56+
public fun encodeBsonValue(value: BsonValue)
7957
}
8058

8159
/**

0 commit comments

Comments
 (0)