Skip to content

Commit 5db2353

Browse files
committed
JAVA-2809 Deprecate snapshot option for the find command
This option is deprecated in MongoDB 3.6 and removed in MongoDB 4.0, so deprecating it in the driver as well.
1 parent 0e2f1ef commit 5db2353

File tree

8 files changed

+18
-0
lines changed

8 files changed

+18
-0
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
@@ -244,6 +244,8 @@ public interface FindIterable<T> extends MongoIterable<T> {
244244
* @param snapshot the snapshot
245245
* @return this
246246
* @since 3.5
247+
* @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release
247248
*/
249+
@Deprecated
248250
FindIterable<T> snapshot(boolean snapshot);
249251
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public FindIterable<TResult> showRecordId(final boolean showRecordId) {
185185
}
186186

187187
@Override
188+
@Deprecated
188189
public FindIterable<TResult> snapshot(final boolean snapshot) {
189190
findOptions.snapshot(snapshot);
190191
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
@@ -581,7 +581,9 @@ public FindOptions showRecordId(final boolean showRecordId) {
581581
*
582582
* @return the snapshot
583583
* @since 3.5
584+
* @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release
584585
*/
586+
@Deprecated
585587
public boolean isSnapshot() {
586588
return snapshot;
587589
}
@@ -594,7 +596,9 @@ public boolean isSnapshot() {
594596
* @param snapshot the snapshot
595597
* @return this
596598
* @since 3.5
599+
* @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release
597600
*/
601+
@Deprecated
598602
public FindOptions snapshot(final boolean snapshot) {
599603
this.snapshot = snapshot;
600604
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
@@ -667,7 +667,9 @@ public FindOperation<T> showRecordId(final boolean showRecordId) {
667667
*
668668
* @return the snapshot
669669
* @since 3.5
670+
* @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release
670671
*/
672+
@Deprecated
671673
public boolean isSnapshot() {
672674
return snapshot;
673675
}
@@ -680,7 +682,9 @@ public boolean isSnapshot() {
680682
* @param snapshot the snapshot
681683
* @return this
682684
* @since 3.5
685+
* @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release
683686
*/
687+
@Deprecated
684688
public FindOperation<T> snapshot(final boolean snapshot) {
685689
this.snapshot = snapshot;
686690
return this;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public int getBatchSize() {
292292
* @return {@code this} so calls can be chained
293293
* @mongodb.driver.manual reference/operator Special Operators
294294
*/
295+
@SuppressWarnings("deprecation")
295296
public DBCursor addSpecial(@Nullable final String name, @Nullable final Object value) {
296297
if (name == null || value == null) {
297298
return this;
@@ -461,7 +462,9 @@ public DBCursor maxTime(final long maxTime, final TimeUnit timeUnit) {
461462
* @see com.mongodb.DBCursor#sort(DBObject)
462463
* @see com.mongodb.DBCursor#hint(DBObject)
463464
* @mongodb.driver.manual reference/operator/meta/snapshot/ $snapshot
465+
* @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release
464466
*/
467+
@Deprecated
465468
public DBCursor snapshot() {
466469
findOptions.getModifiers().put("$snapshot", true);
467470
return this;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void testCount() {
8383
}
8484

8585
@Test
86+
@SuppressWarnings("deprecation")
8687
public void testSnapshot() {
8788
assumeTrue(serverVersionLessThan("3.7"));
8889
insertTestData(collection, 100);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ public interface FindIterable<TResult> extends MongoIterable<TResult> {
245245
* @param snapshot the snapshot
246246
* @return this
247247
* @since 3.5
248+
* @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release
248249
*/
250+
@Deprecated
249251
FindIterable<TResult> snapshot(boolean snapshot);
250252
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public FindIterable<TResult> showRecordId(final boolean showRecordId) {
186186
}
187187

188188
@Override
189+
@Deprecated
189190
public FindIterable<TResult> snapshot(final boolean snapshot) {
190191
findOptions.snapshot(snapshot);
191192
return this;

0 commit comments

Comments
 (0)