Skip to content

Commit d4b899f

Browse files
committed
Apply uuid representation from MongoClientURI to MongoClientOptions
JAVA-3688
1 parent 5e0cfaf commit d4b899f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

driver-legacy/src/main/com/mongodb/MongoClientURI.java

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.mongodb;
1818

1919
import com.mongodb.lang.Nullable;
20+
import org.bson.UuidRepresentation;
2021

2122
import java.util.List;
2223

@@ -419,6 +420,10 @@ public MongoClientOptions getOptions() {
419420
if (!proxied.getCompressorList().isEmpty()) {
420421
builder.compressorList(proxied.getCompressorList());
421422
}
423+
UuidRepresentation uuidRepresentation = proxied.getUuidRepresentation();
424+
if (uuidRepresentation != null) {
425+
builder.uuidRepresentation(uuidRepresentation);
426+
}
422427
return builder.build();
423428
}
424429

driver-legacy/src/test/unit/com/mongodb/MongoClientURISpecification.groovy

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.mongodb
1818

19-
19+
import org.bson.UuidRepresentation
2020
import spock.lang.IgnoreIf
2121
import spock.lang.Specification
2222
import spock.lang.Unroll
@@ -140,6 +140,7 @@ class MongoClientURISpecification extends Specification {
140140
+ 'heartbeatFrequencyMS=20000&'
141141
+ 'retryWrites=true&'
142142
+ 'retryReads=true&'
143+
+ 'uuidRepresentation=csharpLegacy&'
143144
+ 'appName=app1')
144145

145146
when:
@@ -164,6 +165,7 @@ class MongoClientURISpecification extends Specification {
164165
options.getHeartbeatFrequency() == 20000
165166
options.getRetryWrites()
166167
options.getRetryReads()
168+
options.getUuidRepresentation() == UuidRepresentation.C_SHARP_LEGACY
167169
options.getApplicationName() == 'app1'
168170
}
169171

@@ -183,6 +185,7 @@ class MongoClientURISpecification extends Specification {
183185
!options.isSslEnabled()
184186
options.getRetryWrites()
185187
options.getRetryReads()
188+
options.getUuidRepresentation() == UuidRepresentation.JAVA_LEGACY
186189
}
187190

188191
def 'should apply default uri to options'() {
@@ -214,6 +217,7 @@ class MongoClientURISpecification extends Specification {
214217
.localThreshold(25)
215218
.requiredReplicaSetName('test')
216219
.compressorList([MongoCompressor.createZlibCompressor()])
220+
.uuidRepresentation(UuidRepresentation.C_SHARP_LEGACY)
217221

218222
when:
219223
def options = new MongoClientURI('mongodb://localhost', optionsBuilder).getOptions()
@@ -246,6 +250,7 @@ class MongoClientURISpecification extends Specification {
246250
options.getServerSettings().getHeartbeatFrequency(MILLISECONDS) == 5
247251
options.getServerSettings().getMinHeartbeatFrequency(MILLISECONDS) == 11
248252
options.compressorList == [MongoCompressor.createZlibCompressor()]
253+
options.getUuidRepresentation() == UuidRepresentation.C_SHARP_LEGACY
249254
}
250255

251256
@Unroll

0 commit comments

Comments
 (0)