Skip to content

Remove deprecated oplogReplay-related methods #1252

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

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<CurrentIssues>
<ID>IteratorNotThrowingNoSuchElementException:MongoCursor.kt$MongoCursor&lt;T : Any> : IteratorCloseable</ID>
<ID>LargeClass:MongoCollectionTest.kt$MongoCollectionTest</ID>
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Suppress("DEPRECATION") @Test fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Suppress("DEPRECATION") @Test fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:KotlinSerializerCodecTest.kt$KotlinSerializerCodecTest$@Test fun testDataClassOptionalBsonValues()</ID>
<ID>MaxLineLength:MapReduceFlow.kt$MapReduceFlow$*</ID>
<ID>MaxLineLength:MapReduceIterable.kt$MapReduceIterable$*</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public final class FindOptions {
private Bson sort;
private CursorType cursorType = CursorType.NonTailable;
private boolean noCursorTimeout;
private boolean oplogReplay;
private boolean partial;
private Collation collation;
private BsonValue comment;
Expand All @@ -65,7 +64,7 @@ public FindOptions() {
//CHECKSTYLE:OFF
FindOptions(
final int batchSize, final int limit, final Bson projection, final long maxTimeMS, final long maxAwaitTimeMS, final int skip,
final Bson sort, final CursorType cursorType, final boolean noCursorTimeout, final boolean oplogReplay, final boolean partial,
final Bson sort, final CursorType cursorType, final boolean noCursorTimeout, final boolean partial,
final Collation collation, final BsonValue comment, final Bson hint, final String hintString, final Bson variables,
final Bson max, final Bson min, final boolean returnKey, final boolean showRecordId, final Boolean allowDiskUse) {
this.batchSize = batchSize;
Expand All @@ -77,7 +76,6 @@ public FindOptions() {
this.sort = sort;
this.cursorType = cursorType;
this.noCursorTimeout = noCursorTimeout;
this.oplogReplay = oplogReplay;
this.partial = partial;
this.collation = collation;
this.comment = comment;
Expand All @@ -94,7 +92,7 @@ public FindOptions() {

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

/**
Expand Down Expand Up @@ -295,26 +293,6 @@ public FindOptions noCursorTimeout(final boolean noCursorTimeout) {
return this;
}

/**
* Users should not set this under normal circumstances.
*
* @return if oplog replay is enabled
*/
public boolean isOplogReplay() {
return oplogReplay;
}

/**
* Users should not set this under normal circumstances.
*
* @param oplogReplay if oplog replay is enabled
* @return this
*/
public FindOptions oplogReplay(final boolean oplogReplay) {
this.oplogReplay = oplogReplay;
return this;
}

/**
* Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class FindOperation<T> implements AsyncExplainableReadOperation<AsyncBatc
private int skip;
private BsonDocument sort;
private CursorType cursorType = CursorType.NonTailable;
private boolean oplogReplay;
private boolean noCursorTimeout;
private boolean partial;
private Collation collation;
Expand Down Expand Up @@ -198,15 +197,6 @@ public FindOperation<T> cursorType(final CursorType cursorType) {
return this;
}

public boolean isOplogReplay() {
return oplogReplay;
}

public FindOperation<T> oplogReplay(final boolean oplogReplay) {
this.oplogReplay = oplogReplay;
return this;
}

public boolean isNoCursorTimeout() {
return noCursorTimeout;
}
Expand Down Expand Up @@ -420,9 +410,6 @@ private BsonDocument getCommand(final SessionContext sessionContext, final int m
if (isAwaitData()) {
commandDocument.put("awaitData", BsonBoolean.TRUE);
}
if (oplogReplay) {
commandDocument.put("oplogReplay", BsonBoolean.TRUE);
}
if (noCursorTimeout) {
commandDocument.put("noCursorTimeout", BsonBoolean.TRUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ private <TResult> FindOperation<TResult> createFindOperation(final MongoNamespac
.sort(toBsonDocument(options.getSort()))
.cursorType(options.getCursorType())
.noCursorTimeout(options.isNoCursorTimeout())
.oplogReplay(options.isOplogReplay())
.partial(options.isPartial())
.collation(options.getCollation())
.comment(options.getComment())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
operation.getProjection() == null
operation.getCollation() == null
!operation.isNoCursorTimeout()
!operation.isOplogReplay()
!operation.isPartial()
operation.isAllowDiskUse() == null
}
Expand All @@ -119,7 +118,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
.cursorType(Tailable)
.collation(defaultCollation)
.partial(true)
.oplogReplay(true)
.noCursorTimeout(true)
.allowDiskUse(true)

Expand All @@ -134,7 +132,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
operation.getProjection() == projection
operation.getCollation() == defaultCollation
operation.isNoCursorTimeout()
operation.isOplogReplay()
operation.isPartial()
operation.isAllowDiskUse()
}
Expand Down Expand Up @@ -709,7 +706,6 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
def operation = new FindOperation<BsonDocument>(namespace, new BsonDocumentCodec())
.noCursorTimeout(true)
.partial(true)
.oplogReplay(true)

when:
execute(operation, async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class FindOptionsSpecification extends Specification {
options.getBatchSize() == 0
options.getCursorType() == CursorType.NonTailable
!options.isNoCursorTimeout()
!options.isOplogReplay()
!options.isPartial()
!options.isAllowDiskUse()
}
Expand Down Expand Up @@ -113,14 +112,6 @@ class FindOptionsSpecification extends Specification {
partial << [true, false]
}

def 'should set oplogReplay'() {
expect:
new FindOptions().oplogReplay(oplogReplay).isOplogReplay() == oplogReplay

where:
oplogReplay << [true, false]
}

def 'should set noCursorTimeout'() {
expect:
new FindOptions().noCursorTimeout(noCursorTimeout).isNoCursorTimeout() == noCursorTimeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ class FindOperationUnitSpecification extends OperationUnitSpecification {
.limit(limit)
.batchSize(batchSize)
.cursorType(TailableAwait)
.oplogReplay(true)
.noCursorTimeout(true)
.partial(true)
.oplogReplay(true)
.maxTime(10, MILLISECONDS)
.comment(new BsonString('my comment'))
.hint(BsonDocument.parse('{ hint : 1}'))
Expand All @@ -70,7 +68,6 @@ class FindOperationUnitSpecification extends OperationUnitSpecification {
.append('awaitData', BsonBoolean.TRUE)
.append('allowPartialResults', BsonBoolean.TRUE)
.append('noCursorTimeout', BsonBoolean.TRUE)
.append('oplogReplay', BsonBoolean.TRUE)
.append('maxTimeMS', new BsonInt64(operation.getMaxTime(MILLISECONDS)))
.append('comment', operation.getComment())
.append('hint', operation.getHint())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.bson.BsonValue
import org.bson.Document
import org.bson.conversions.Bson

@Suppress("DEPRECATION")
data class SyncFindIterable<T : Any>(val wrapped: FindFlow<T>) : JFindIterable<T>, SyncMongoIterable<T>(wrapped) {
override fun batchSize(batchSize: Int): SyncFindIterable<T> = apply { wrapped.batchSize(batchSize) }
override fun filter(filter: Bson?): SyncFindIterable<T> = apply { wrapped.filter(filter) }
Expand Down Expand Up @@ -55,9 +54,6 @@ data class SyncFindIterable<T : Any>(val wrapped: FindFlow<T>) : JFindIterable<T
wrapped.noCursorTimeout(noCursorTimeout)
}

@Suppress("OVERRIDE_DEPRECATION")
override fun oplogReplay(oplogReplay: Boolean): SyncFindIterable<T> = apply { wrapped.oplogReplay(oplogReplay) }

override fun partial(partial: Boolean): SyncFindIterable<T> = apply { wrapped.partial(partial) }

override fun cursorType(cursorType: CursorType): SyncFindIterable<T> = apply { wrapped.cursorType(cursorType) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,6 @@ public class FindFlow<T : Any>(private val wrapped: FindPublisher<T>) : Flow<T>
wrapped.noCursorTimeout(noCursorTimeout)
}

/**
* Users should not set this under normal circumstances.
*
* @param oplogReplay if oplog replay is enabled
* @return this
* @deprecated oplogReplay has been deprecated in MongoDB 4.4.
*/
@Suppress("DEPRECATION")
@Deprecated("oplogReplay has been deprecated in MongoDB 4.4", replaceWith = ReplaceWith(""))
public fun oplogReplay(oplogReplay: Boolean): FindFlow<T> = apply { wrapped.oplogReplay(oplogReplay) }

/**
* Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ import org.bson.BsonDocument
import org.bson.BsonString
import org.bson.Document
import org.junit.jupiter.api.Test
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoMoreInteractions
import org.mockito.kotlin.whenever
import org.mockito.kotlin.*
import reactor.core.publisher.Mono

class FindFlowTest {
Expand All @@ -44,7 +39,6 @@ class FindFlowTest {
assertEquals(jFindPublisherFunctions, kFindFlowFunctions)
}

@Suppress("DEPRECATION")
@Test
fun shouldCallTheUnderlyingMethods() {
val wrapped: FindPublisher<Document> = mock()
Expand Down Expand Up @@ -77,7 +71,6 @@ class FindFlowTest {
flow.maxTime(1)
flow.maxTime(1, TimeUnit.SECONDS)
flow.min(bson)
flow.oplogReplay(true)
flow.noCursorTimeout(true)
flow.partial(true)
flow.projection(bson)
Expand All @@ -103,7 +96,6 @@ class FindFlowTest {
verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).min(bson)
verify(wrapped).oplogReplay(true)
verify(wrapped).noCursorTimeout(true)
verify(wrapped).partial(true)
verify(wrapped).projection(bson)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import org.bson.BsonValue
import org.bson.Document
import org.bson.conversions.Bson

@Suppress("DEPRECATION")
internal class SyncFindIterable<T : Any>(val wrapped: FindIterable<T>) :
JFindIterable<T>, SyncMongoIterable<T>(wrapped) {
override fun batchSize(batchSize: Int): SyncFindIterable<T> = apply { wrapped.batchSize(batchSize) }
Expand Down Expand Up @@ -55,9 +54,6 @@ internal class SyncFindIterable<T : Any>(val wrapped: FindIterable<T>) :
wrapped.noCursorTimeout(noCursorTimeout)
}

@Suppress("OVERRIDE_DEPRECATION")
override fun oplogReplay(oplogReplay: Boolean): SyncFindIterable<T> = apply { wrapped.oplogReplay(oplogReplay) }

override fun partial(partial: Boolean): SyncFindIterable<T> = apply { wrapped.partial(partial) }

override fun cursorType(cursorType: CursorType): SyncFindIterable<T> = apply { wrapped.cursorType(cursorType) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,6 @@ public class FindIterable<T : Any>(private val wrapped: JFindIterable<T>) : Mong
wrapped.noCursorTimeout(noCursorTimeout)
}

/**
* Users should not set this under normal circumstances.
*
* @param oplogReplay if oplog replay is enabled
* @return this
* @deprecated oplogReplay has been deprecated in MongoDB 4.4.
*/
@Suppress("DEPRECATION")
@Deprecated("oplogReplay has been deprecated in MongoDB 4.4", replaceWith = ReplaceWith(""))
public fun oplogReplay(oplogReplay: Boolean): FindIterable<T> = apply { wrapped.oplogReplay(oplogReplay) }

/**
* Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ import org.bson.BsonDocument
import org.bson.BsonString
import org.bson.Document
import org.junit.jupiter.api.Test
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoMoreInteractions
import org.mockito.kotlin.whenever
import org.mockito.kotlin.*

class FindIterableTest {
@Test
Expand All @@ -42,7 +37,6 @@ class FindIterableTest {
assertEquals(jFindIterableFunctions, kFindIterableFunctions)
}

@Suppress("DEPRECATION")
@Test
fun shouldCallTheUnderlyingMethods() {
val wrapped: JFindIterable<Document> = mock()
Expand Down Expand Up @@ -85,7 +79,6 @@ class FindIterableTest {
iterable.maxTime(1)
iterable.maxTime(1, TimeUnit.SECONDS)
iterable.min(bson)
iterable.oplogReplay(true)
iterable.noCursorTimeout(true)
iterable.partial(true)
iterable.projection(bson)
Expand Down Expand Up @@ -114,7 +107,6 @@ class FindIterableTest {
verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).min(bson)
verify(wrapped).oplogReplay(true)
verify(wrapped).noCursorTimeout(true)
verify(wrapped).partial(true)
verify(wrapped).projection(bson)
Expand Down
16 changes: 0 additions & 16 deletions driver-legacy/src/main/com/mongodb/DBCursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,20 +387,6 @@ public DBCursor cursorType(final CursorType cursorType) {
return this;
}

/**
* Users should not set this under normal circumstances.
*
* @param oplogReplay if oplog replay is enabled
* @return this
* @since 3.9
* @deprecated oplogReplay has been deprecated in MongoDB 4.4.
*/
@Deprecated
public DBCursor oplogReplay(final boolean oplogReplay) {
findOptions.oplogReplay(oplogReplay);
return this;
}

/**
* The server normally times out idle cursors after an inactivity period (10 minutes)
* to prevent excess memory use. Set this option to prevent that.
Expand All @@ -426,7 +412,6 @@ public DBCursor partial(final boolean partial) {
return this;
}

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

return new FindOperation<>(collection.getNamespace(), decoder)
Expand All @@ -449,7 +434,6 @@ private FindOperation<DBObject> getQueryOperation(final Decoder<DBObject> decode
.max(collection.wrapAllowNull(findOptions.getMax()))
.cursorType(findOptions.getCursorType())
.noCursorTimeout(findOptions.isNoCursorTimeout())
.oplogReplay(findOptions.isOplogReplay())
.partial(findOptions.isPartial())
.returnKey(findOptions.isReturnKey())
.showRecordId(findOptions.isShowRecordId())
Expand Down
Loading