Skip to content

Commit 0e2f1ef

Browse files
committed
JAVA-2808 Deprecate maxScan option for the find command
This option is deprecated in MongoDB 4.0 and will be removed in a future release of the server, so deprecating it in the driver as well.
1 parent 4b6a82c commit 0e2f1ef

File tree

8 files changed

+19
-2
lines changed

8 files changed

+19
-2
lines changed

driver-async/src/main/com/mongodb/async/client/FindIterable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ public interface FindIterable<T> extends MongoIterable<T> {
213213
* @param maxScan the maxScan
214214
* @return this
215215
* @since 3.5
216+
* @deprecated Deprecated as of MongoDB 4.0 release
216217
*/
218+
@Deprecated
217219
FindIterable<T> maxScan(long maxScan);
218220

219221
/**

driver-async/src/main/com/mongodb/async/client/FindIterableImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public FindIterable<TResult> min(@Nullable final Bson min) {
166166
}
167167

168168
@Override
169+
@Deprecated
169170
public FindIterable<TResult> maxScan(final long maxScan) {
170171
findOptions.maxScan(maxScan);
171172
return this;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,9 @@ public FindOptions min(@Nullable final Bson min) {
502502
*
503503
* @return the maxScan
504504
* @since 3.5
505+
* @deprecated Deprecated as of MongoDB 4.0 release
505506
*/
507+
@Deprecated
506508
public long getMaxScan() {
507509
return maxScan;
508510
}
@@ -515,7 +517,9 @@ public long getMaxScan() {
515517
* @param maxScan the maxScan
516518
* @return this
517519
* @since 3.5
520+
* @deprecated Deprecated as of MongoDB 4.0 release
518521
*/
522+
@Deprecated
519523
public FindOptions maxScan(final long maxScan) {
520524
this.maxScan = maxScan;
521525
return this;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@ public FindOperation<T> min(final BsonDocument min) {
588588
*
589589
* @return the maxScan
590590
* @since 3.5
591+
* @deprecated Deprecated as of MongoDB 4.0 release
591592
*/
593+
@Deprecated
592594
public long getMaxScan() {
593595
return maxScan;
594596
}
@@ -601,7 +603,9 @@ public long getMaxScan() {
601603
* @param maxScan the maxScan
602604
* @return this
603605
* @since 3.5
606+
* @deprecated Deprecated as of MongoDB 4.0 release
604607
*/
608+
@Deprecated
605609
public FindOperation<T> maxScan(final long maxScan) {
606610
this.maxScan = maxScan;
607611
return this;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ public int getBatchSize() {
281281
}
282282

283283
/**
284-
* Adds a special operator like $maxScan or $returnKey. For example:
284+
* Adds a special operator like $comment or $returnKey. For example:
285285
* <pre>
286286
* addSpecial("$returnKey", 1)
287-
* addSpecial("$maxScan", 100)
287+
* addSpecial("$comment", "this is a special query)
288288
* </pre>
289289
*
290290
* @param name the name of the special query operator
@@ -352,7 +352,9 @@ public DBCursor comment(final String comment) {
352352
* @mongodb.driver.manual reference/operator/meta/maxScan/ $maxScan
353353
* @see #limit(int)
354354
* @since 2.12
355+
* @deprecated Deprecated as of MongoDB 4.0 release
355356
*/
357+
@Deprecated
356358
public DBCursor maxScan(final int max) {
357359
findOptions.getModifiers().put("$maxScan", max);
358360
return this;

driver-legacy/src/test/functional/com/mongodb/DBCursorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ public void testConstructor() {
309309
}
310310

311311
@Test
312+
@SuppressWarnings("deprecation")
312313
public void testMaxScan() {
313314
countResults(new DBCursor(collection, new BasicDBObject(), new BasicDBObject(), ReadPreference.primary())
314315
.addSpecial("$maxScan", 4), 4);

driver-sync/src/main/com/mongodb/client/FindIterable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ public interface FindIterable<TResult> extends MongoIterable<TResult> {
214214
* @param maxScan the maxScan
215215
* @return this
216216
* @since 3.5
217+
* @deprecated Deprecated as of MongoDB 4.0 release
217218
*/
219+
@Deprecated
218220
FindIterable<TResult> maxScan(long maxScan);
219221

220222
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public FindIterable<TResult> min(@Nullable final Bson min) {
167167
}
168168

169169
@Override
170+
@Deprecated
170171
public FindIterable<TResult> maxScan(final long maxScan) {
171172
findOptions.maxScan(maxScan);
172173
return this;

0 commit comments

Comments
 (0)