Skip to content

Commit c5dd111

Browse files
committed
Remove deprecated oplogReplay-related methods (#1252)
JAVA-5150
1 parent 20bad8b commit c5dd111

File tree

27 files changed

+10
-223
lines changed

27 files changed

+10
-223
lines changed

config/detekt/baseline.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<CurrentIssues>
55
<ID>IteratorNotThrowingNoSuchElementException:MongoCursor.kt$MongoCursor&lt;T : Any> : IteratorCloseable</ID>
66
<ID>LargeClass:MongoCollectionTest.kt$MongoCollectionTest</ID>
7-
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Suppress("DEPRECATION") @Test fun shouldCallTheUnderlyingMethods()</ID>
8-
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Suppress("DEPRECATION") @Test fun shouldCallTheUnderlyingMethods()</ID>
7+
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
8+
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
99
<ID>LongMethod:KotlinSerializerCodecTest.kt$KotlinSerializerCodecTest$@Test fun testDataClassOptionalBsonValues()</ID>
1010
<ID>MaxLineLength:MapReduceFlow.kt$MapReduceFlow$*</ID>
1111
<ID>MaxLineLength:MapReduceIterable.kt$MapReduceIterable$*</ID>

driver-core/src/main/com/mongodb/internal/client/model/FindOptions.java

+2-24
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public final class FindOptions {
4343
private Bson sort;
4444
private CursorType cursorType = CursorType.NonTailable;
4545
private boolean noCursorTimeout;
46-
private boolean oplogReplay;
4746
private boolean partial;
4847
private Collation collation;
4948
private BsonValue comment;
@@ -65,7 +64,7 @@ public FindOptions() {
6564
//CHECKSTYLE:OFF
6665
FindOptions(
6766
final int batchSize, final int limit, final Bson projection, final long maxTimeMS, final long maxAwaitTimeMS, final int skip,
68-
final Bson sort, final CursorType cursorType, final boolean noCursorTimeout, final boolean oplogReplay, final boolean partial,
67+
final Bson sort, final CursorType cursorType, final boolean noCursorTimeout, final boolean partial,
6968
final Collation collation, final BsonValue comment, final Bson hint, final String hintString, final Bson variables,
7069
final Bson max, final Bson min, final boolean returnKey, final boolean showRecordId, final Boolean allowDiskUse) {
7170
this.batchSize = batchSize;
@@ -77,7 +76,6 @@ public FindOptions() {
7776
this.sort = sort;
7877
this.cursorType = cursorType;
7978
this.noCursorTimeout = noCursorTimeout;
80-
this.oplogReplay = oplogReplay;
8179
this.partial = partial;
8280
this.collation = collation;
8381
this.comment = comment;
@@ -94,7 +92,7 @@ public FindOptions() {
9492

9593
public FindOptions withBatchSize(final int batchSize) {
9694
return new FindOptions(batchSize, limit, projection, maxTimeMS, maxAwaitTimeMS, skip, sort, cursorType, noCursorTimeout,
97-
oplogReplay, partial, collation, comment, hint, hintString, variables, max, min, returnKey, showRecordId, allowDiskUse);
95+
partial, collation, comment, hint, hintString, variables, max, min, returnKey, showRecordId, allowDiskUse);
9896
}
9997

10098
/**
@@ -295,26 +293,6 @@ public FindOptions noCursorTimeout(final boolean noCursorTimeout) {
295293
return this;
296294
}
297295

298-
/**
299-
* Users should not set this under normal circumstances.
300-
*
301-
* @return if oplog replay is enabled
302-
*/
303-
public boolean isOplogReplay() {
304-
return oplogReplay;
305-
}
306-
307-
/**
308-
* Users should not set this under normal circumstances.
309-
*
310-
* @param oplogReplay if oplog replay is enabled
311-
* @return this
312-
*/
313-
public FindOptions oplogReplay(final boolean oplogReplay) {
314-
this.oplogReplay = oplogReplay;
315-
return this;
316-
}
317-
318296
/**
319297
* Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
320298
*

driver-core/src/main/com/mongodb/internal/operation/FindOperation.java

-13
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public class FindOperation<T> implements AsyncExplainableReadOperation<AsyncBatc
8383
private int skip;
8484
private BsonDocument sort;
8585
private CursorType cursorType = CursorType.NonTailable;
86-
private boolean oplogReplay;
8786
private boolean noCursorTimeout;
8887
private boolean partial;
8988
private Collation collation;
@@ -196,15 +195,6 @@ public FindOperation<T> cursorType(final CursorType cursorType) {
196195
return this;
197196
}
198197

199-
public boolean isOplogReplay() {
200-
return oplogReplay;
201-
}
202-
203-
public FindOperation<T> oplogReplay(final boolean oplogReplay) {
204-
this.oplogReplay = oplogReplay;
205-
return this;
206-
}
207-
208198
public boolean isNoCursorTimeout() {
209199
return noCursorTimeout;
210200
}
@@ -418,9 +408,6 @@ private BsonDocument getCommand(final SessionContext sessionContext, final int m
418408
if (isAwaitData()) {
419409
commandDocument.put("awaitData", BsonBoolean.TRUE);
420410
}
421-
if (oplogReplay) {
422-
commandDocument.put("oplogReplay", BsonBoolean.TRUE);
423-
}
424411
if (noCursorTimeout) {
425412
commandDocument.put("noCursorTimeout", BsonBoolean.TRUE);
426413
}

driver-core/src/main/com/mongodb/internal/operation/Operations.java

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ private <TResult> FindOperation<TResult> createFindOperation(final MongoNamespac
197197
.sort(toBsonDocument(options.getSort()))
198198
.cursorType(options.getCursorType())
199199
.noCursorTimeout(options.isNoCursorTimeout())
200-
.oplogReplay(options.isOplogReplay())
201200
.partial(options.isPartial())
202201
.collation(options.getCollation())
203202
.comment(options.getComment())

driver-core/src/test/functional/com/mongodb/internal/operation/FindOperationSpecification.groovy

-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
9595
operation.getProjection() == null
9696
operation.getCollation() == null
9797
!operation.isNoCursorTimeout()
98-
!operation.isOplogReplay()
9998
!operation.isPartial()
10099
operation.isAllowDiskUse() == null
101100
}
@@ -119,7 +118,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
119118
.cursorType(Tailable)
120119
.collation(defaultCollation)
121120
.partial(true)
122-
.oplogReplay(true)
123121
.noCursorTimeout(true)
124122
.allowDiskUse(true)
125123

@@ -134,7 +132,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
134132
operation.getProjection() == projection
135133
operation.getCollation() == defaultCollation
136134
operation.isNoCursorTimeout()
137-
operation.isOplogReplay()
138135
operation.isPartial()
139136
operation.isAllowDiskUse()
140137
}
@@ -709,7 +706,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
709706
def operation = new FindOperation<BsonDocument>(namespace, new BsonDocumentCodec())
710707
.noCursorTimeout(true)
711708
.partial(true)
712-
.oplogReplay(true)
713709

714710
when:
715711
execute(operation, async)

driver-core/src/test/unit/com/mongodb/client/model/FindOptionsSpecification.groovy

-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class FindOptionsSpecification extends Specification {
4444
options.getBatchSize() == 0
4545
options.getCursorType() == CursorType.NonTailable
4646
!options.isNoCursorTimeout()
47-
!options.isOplogReplay()
4847
!options.isPartial()
4948
!options.isAllowDiskUse()
5049
}
@@ -113,14 +112,6 @@ class FindOptionsSpecification extends Specification {
113112
partial << [true, false]
114113
}
115114

116-
def 'should set oplogReplay'() {
117-
expect:
118-
new FindOptions().oplogReplay(oplogReplay).isOplogReplay() == oplogReplay
119-
120-
where:
121-
oplogReplay << [true, false]
122-
}
123-
124115
def 'should set noCursorTimeout'() {
125116
expect:
126117
new FindOptions().noCursorTimeout(noCursorTimeout).isNoCursorTimeout() == noCursorTimeout

driver-core/src/test/unit/com/mongodb/internal/operation/FindOperationUnitSpecification.groovy

-3
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ class FindOperationUnitSpecification extends OperationUnitSpecification {
4747
.limit(limit)
4848
.batchSize(batchSize)
4949
.cursorType(TailableAwait)
50-
.oplogReplay(true)
5150
.noCursorTimeout(true)
5251
.partial(true)
53-
.oplogReplay(true)
5452
.maxTime(10, MILLISECONDS)
5553
.comment(new BsonString('my comment'))
5654
.hint(BsonDocument.parse('{ hint : 1}'))
@@ -70,7 +68,6 @@ class FindOperationUnitSpecification extends OperationUnitSpecification {
7068
.append('awaitData', BsonBoolean.TRUE)
7169
.append('allowPartialResults', BsonBoolean.TRUE)
7270
.append('noCursorTimeout', BsonBoolean.TRUE)
73-
.append('oplogReplay', BsonBoolean.TRUE)
7471
.append('maxTimeMS', new BsonInt64(operation.getMaxTime(MILLISECONDS)))
7572
.append('comment', operation.getComment())
7673
.append('hint', operation.getHint())

driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncFindIterable.kt

-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import org.bson.BsonValue
2626
import org.bson.Document
2727
import org.bson.conversions.Bson
2828

29-
@Suppress("DEPRECATION")
3029
data class SyncFindIterable<T : Any>(val wrapped: FindFlow<T>) : JFindIterable<T>, SyncMongoIterable<T>(wrapped) {
3130
override fun batchSize(batchSize: Int): SyncFindIterable<T> = apply { wrapped.batchSize(batchSize) }
3231
override fun filter(filter: Bson?): SyncFindIterable<T> = apply { wrapped.filter(filter) }
@@ -55,9 +54,6 @@ data class SyncFindIterable<T : Any>(val wrapped: FindFlow<T>) : JFindIterable<T
5554
wrapped.noCursorTimeout(noCursorTimeout)
5655
}
5756

58-
@Suppress("OVERRIDE_DEPRECATION")
59-
override fun oplogReplay(oplogReplay: Boolean): SyncFindIterable<T> = apply { wrapped.oplogReplay(oplogReplay) }
60-
6157
override fun partial(partial: Boolean): SyncFindIterable<T> = apply { wrapped.partial(partial) }
6258

6359
override fun cursorType(cursorType: CursorType): SyncFindIterable<T> = apply { wrapped.cursorType(cursorType) }

driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/FindFlow.kt

-11
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,6 @@ public class FindFlow<T : Any>(private val wrapped: FindPublisher<T>) : Flow<T>
131131
wrapped.noCursorTimeout(noCursorTimeout)
132132
}
133133

134-
/**
135-
* Users should not set this under normal circumstances.
136-
*
137-
* @param oplogReplay if oplog replay is enabled
138-
* @return this
139-
* @deprecated oplogReplay has been deprecated in MongoDB 4.4.
140-
*/
141-
@Suppress("DEPRECATION")
142-
@Deprecated("oplogReplay has been deprecated in MongoDB 4.4", replaceWith = ReplaceWith(""))
143-
public fun oplogReplay(oplogReplay: Boolean): FindFlow<T> = apply { wrapped.oplogReplay(oplogReplay) }
144-
145134
/**
146135
* Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
147136
*

driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/FindFlowTest.kt

+1-9
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ import org.bson.BsonDocument
2727
import org.bson.BsonString
2828
import org.bson.Document
2929
import org.junit.jupiter.api.Test
30-
import org.mockito.kotlin.doReturn
31-
import org.mockito.kotlin.mock
32-
import org.mockito.kotlin.times
33-
import org.mockito.kotlin.verify
34-
import org.mockito.kotlin.verifyNoMoreInteractions
35-
import org.mockito.kotlin.whenever
30+
import org.mockito.kotlin.*
3631
import reactor.core.publisher.Mono
3732

3833
class FindFlowTest {
@@ -44,7 +39,6 @@ class FindFlowTest {
4439
assertEquals(jFindPublisherFunctions, kFindFlowFunctions)
4540
}
4641

47-
@Suppress("DEPRECATION")
4842
@Test
4943
fun shouldCallTheUnderlyingMethods() {
5044
val wrapped: FindPublisher<Document> = mock()
@@ -77,7 +71,6 @@ class FindFlowTest {
7771
flow.maxTime(1)
7872
flow.maxTime(1, TimeUnit.SECONDS)
7973
flow.min(bson)
80-
flow.oplogReplay(true)
8174
flow.noCursorTimeout(true)
8275
flow.partial(true)
8376
flow.projection(bson)
@@ -103,7 +96,6 @@ class FindFlowTest {
10396
verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
10497
verify(wrapped).maxTime(1, TimeUnit.SECONDS)
10598
verify(wrapped).min(bson)
106-
verify(wrapped).oplogReplay(true)
10799
verify(wrapped).noCursorTimeout(true)
108100
verify(wrapped).partial(true)
109101
verify(wrapped).projection(bson)

driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncFindIterable.kt

-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import org.bson.BsonValue
2525
import org.bson.Document
2626
import org.bson.conversions.Bson
2727

28-
@Suppress("DEPRECATION")
2928
internal class SyncFindIterable<T : Any>(val wrapped: FindIterable<T>) :
3029
JFindIterable<T>, SyncMongoIterable<T>(wrapped) {
3130
override fun batchSize(batchSize: Int): SyncFindIterable<T> = apply { wrapped.batchSize(batchSize) }
@@ -55,9 +54,6 @@ internal class SyncFindIterable<T : Any>(val wrapped: FindIterable<T>) :
5554
wrapped.noCursorTimeout(noCursorTimeout)
5655
}
5756

58-
@Suppress("OVERRIDE_DEPRECATION")
59-
override fun oplogReplay(oplogReplay: Boolean): SyncFindIterable<T> = apply { wrapped.oplogReplay(oplogReplay) }
60-
6157
override fun partial(partial: Boolean): SyncFindIterable<T> = apply { wrapped.partial(partial) }
6258

6359
override fun cursorType(cursorType: CursorType): SyncFindIterable<T> = apply { wrapped.cursorType(cursorType) }

driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/FindIterable.kt

-11
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,6 @@ public class FindIterable<T : Any>(private val wrapped: JFindIterable<T>) : Mong
126126
wrapped.noCursorTimeout(noCursorTimeout)
127127
}
128128

129-
/**
130-
* Users should not set this under normal circumstances.
131-
*
132-
* @param oplogReplay if oplog replay is enabled
133-
* @return this
134-
* @deprecated oplogReplay has been deprecated in MongoDB 4.4.
135-
*/
136-
@Suppress("DEPRECATION")
137-
@Deprecated("oplogReplay has been deprecated in MongoDB 4.4", replaceWith = ReplaceWith(""))
138-
public fun oplogReplay(oplogReplay: Boolean): FindIterable<T> = apply { wrapped.oplogReplay(oplogReplay) }
139-
140129
/**
141130
* Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
142131
*

driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/FindIterableTest.kt

+1-9
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ import org.bson.BsonDocument
2626
import org.bson.BsonString
2727
import org.bson.Document
2828
import org.junit.jupiter.api.Test
29-
import org.mockito.kotlin.doReturn
30-
import org.mockito.kotlin.mock
31-
import org.mockito.kotlin.times
32-
import org.mockito.kotlin.verify
33-
import org.mockito.kotlin.verifyNoMoreInteractions
34-
import org.mockito.kotlin.whenever
29+
import org.mockito.kotlin.*
3530

3631
class FindIterableTest {
3732
@Test
@@ -42,7 +37,6 @@ class FindIterableTest {
4237
assertEquals(jFindIterableFunctions, kFindIterableFunctions)
4338
}
4439

45-
@Suppress("DEPRECATION")
4640
@Test
4741
fun shouldCallTheUnderlyingMethods() {
4842
val wrapped: JFindIterable<Document> = mock()
@@ -85,7 +79,6 @@ class FindIterableTest {
8579
iterable.maxTime(1)
8680
iterable.maxTime(1, TimeUnit.SECONDS)
8781
iterable.min(bson)
88-
iterable.oplogReplay(true)
8982
iterable.noCursorTimeout(true)
9083
iterable.partial(true)
9184
iterable.projection(bson)
@@ -114,7 +107,6 @@ class FindIterableTest {
114107
verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
115108
verify(wrapped).maxTime(1, TimeUnit.SECONDS)
116109
verify(wrapped).min(bson)
117-
verify(wrapped).oplogReplay(true)
118110
verify(wrapped).noCursorTimeout(true)
119111
verify(wrapped).partial(true)
120112
verify(wrapped).projection(bson)

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

-16
Original file line numberDiff line numberDiff line change
@@ -387,20 +387,6 @@ public DBCursor cursorType(final CursorType cursorType) {
387387
return this;
388388
}
389389

390-
/**
391-
* Users should not set this under normal circumstances.
392-
*
393-
* @param oplogReplay if oplog replay is enabled
394-
* @return this
395-
* @since 3.9
396-
* @deprecated oplogReplay has been deprecated in MongoDB 4.4.
397-
*/
398-
@Deprecated
399-
public DBCursor oplogReplay(final boolean oplogReplay) {
400-
findOptions.oplogReplay(oplogReplay);
401-
return this;
402-
}
403-
404390
/**
405391
* The server normally times out idle cursors after an inactivity period (10 minutes)
406392
* to prevent excess memory use. Set this option to prevent that.
@@ -426,7 +412,6 @@ public DBCursor partial(final boolean partial) {
426412
return this;
427413
}
428414

429-
@SuppressWarnings("deprecation")
430415
private FindOperation<DBObject> getQueryOperation(final Decoder<DBObject> decoder) {
431416

432417
return new FindOperation<>(collection.getNamespace(), decoder)
@@ -449,7 +434,6 @@ private FindOperation<DBObject> getQueryOperation(final Decoder<DBObject> decode
449434
.max(collection.wrapAllowNull(findOptions.getMax()))
450435
.cursorType(findOptions.getCursorType())
451436
.noCursorTimeout(findOptions.isNoCursorTimeout())
452-
.oplogReplay(findOptions.isOplogReplay())
453437
.partial(findOptions.isPartial())
454438
.returnKey(findOptions.isReturnKey())
455439
.showRecordId(findOptions.isShowRecordId())

0 commit comments

Comments
 (0)