Skip to content

Commit b6a9d0d

Browse files
committed
Use wrapped CodecRegistry for MongoClient#watch
JAVA-4773
1 parent fbc5e4e commit b6a9d0d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

driver-sync/src/main/com/mongodb/client/internal/MongoClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public ClusterDescription getClusterDescription() {
203203
private <TResult> ChangeStreamIterable<TResult> createChangeStreamIterable(@Nullable final ClientSession clientSession,
204204
final List<? extends Bson> pipeline,
205205
final Class<TResult> resultClass) {
206-
return new ChangeStreamIterableImpl<>(clientSession, "admin", settings.getCodecRegistry(), settings.getReadPreference(),
206+
return new ChangeStreamIterableImpl<>(clientSession, "admin", delegate.getCodecRegistry(), settings.getReadPreference(),
207207
settings.getReadConcern(), delegate.getOperationExecutor(),
208208
pipeline, resultClass, ChangeStreamLevel.CLIENT, settings.getRetryReads());
209209
}

driver-sync/src/test/unit/com/mongodb/client/MongoClientSpecification.groovy

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ class MongoClientSpecification extends Specification {
123123
.readConcern(ReadConcern.MAJORITY)
124124
.codecRegistry(getDefaultCodecRegistry())
125125
.build()
126-
def codecRegistry = settings.getCodecRegistry()
127126
def readPreference = settings.getReadPreference()
128127
def readConcern = settings.getReadConcern()
129128
def client = new MongoClientImpl(Stub(Cluster), null, settings, executor)
@@ -133,23 +132,26 @@ class MongoClientSpecification extends Specification {
133132
def changeStreamIterable = execute(watchMethod, session)
134133

135134
then:
136-
expect changeStreamIterable, isTheSameAs(new ChangeStreamIterableImpl<>(session, namespace, codecRegistry,
135+
expect changeStreamIterable, isTheSameAs(new ChangeStreamIterableImpl<>(session, namespace,
136+
withUuidRepresentation(getDefaultCodecRegistry(), UNSPECIFIED),
137137
readPreference, readConcern, executor, [], Document, ChangeStreamLevel.CLIENT, true),
138138
['codec'])
139139

140140
when:
141141
changeStreamIterable = execute(watchMethod, session, [new Document('$match', 1)])
142142

143143
then:
144-
expect changeStreamIterable, isTheSameAs(new ChangeStreamIterableImpl<>(session, namespace, codecRegistry,
144+
expect changeStreamIterable, isTheSameAs(new ChangeStreamIterableImpl<>(session, namespace,
145+
withUuidRepresentation(getDefaultCodecRegistry(), UNSPECIFIED),
145146
readPreference, readConcern, executor, [new Document('$match', 1)], Document, ChangeStreamLevel.CLIENT,
146147
true), ['codec'])
147148

148149
when:
149150
changeStreamIterable = execute(watchMethod, session, [new Document('$match', 1)], BsonDocument)
150151

151152
then:
152-
expect changeStreamIterable, isTheSameAs(new ChangeStreamIterableImpl<>(session, namespace, codecRegistry,
153+
expect changeStreamIterable, isTheSameAs(new ChangeStreamIterableImpl<>(session, namespace,
154+
withUuidRepresentation(getDefaultCodecRegistry(), UNSPECIFIED),
153155
readPreference, readConcern, executor, [new Document('$match', 1)], BsonDocument,
154156
ChangeStreamLevel.CLIENT, true), ['codec'])
155157

0 commit comments

Comments
 (0)