Skip to content

Commit e78a2dc

Browse files
authored
Expose Observable[Unit] instead of Observable[Void] (#1282)
JAVA-4303
1 parent 1955b75 commit e78a2dc

16 files changed

+340
-109
lines changed

driver-scala/src/integration/scala/org/mongodb/scala/documentation/DocumentationTransactionsExampleSpec.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class DocumentationTransactionsExampleSpec extends RequiresMongoDBISpec {
7575
})
7676
}
7777

78-
def commitAndRetry(observable: SingleObservable[Void]): SingleObservable[Void] = {
78+
def commitAndRetry(observable: SingleObservable[Unit]): SingleObservable[Unit] = {
7979
observable.recoverWith({
8080
case e: MongoException if e.hasErrorLabel(MongoException.UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL) => {
8181
println("UnknownTransactionCommitResult, retrying commit operation ...")
@@ -88,7 +88,7 @@ class DocumentationTransactionsExampleSpec extends RequiresMongoDBISpec {
8888
})
8989
}
9090

91-
def runTransactionAndRetry(observable: SingleObservable[Void]): SingleObservable[Void] = {
91+
def runTransactionAndRetry(observable: SingleObservable[Unit]): SingleObservable[Unit] = {
9292
observable.recoverWith({
9393
case e: MongoException if e.hasErrorLabel(MongoException.TRANSIENT_TRANSACTION_ERROR_LABEL) => {
9494
println("TransientTransactionError, aborting transaction and retrying ...")
@@ -97,14 +97,14 @@ class DocumentationTransactionsExampleSpec extends RequiresMongoDBISpec {
9797
})
9898
}
9999

100-
def updateEmployeeInfoWithRetry(client: MongoClient): SingleObservable[Void] = {
100+
def updateEmployeeInfoWithRetry(client: MongoClient): SingleObservable[Unit] = {
101101

102102
val database = client.getDatabase("hr")
103103
val updateEmployeeInfoObservable: SingleObservable[ClientSession] =
104104
updateEmployeeInfo(database, client.startSession())
105-
val commitTransactionObservable: SingleObservable[Void] =
105+
val commitTransactionObservable: SingleObservable[Unit] =
106106
updateEmployeeInfoObservable.flatMap(clientSession => clientSession.commitTransaction())
107-
val commitAndRetryObservable: SingleObservable[Void] = commitAndRetry(commitTransactionObservable)
107+
val commitAndRetryObservable: SingleObservable[Unit] = commitAndRetry(commitTransactionObservable)
108108

109109
runTransactionAndRetry(commitAndRetryObservable)
110110
}

driver-scala/src/main/scala/org/mongodb/scala/AggregateObservable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ case class AggregateObservable[TResult](private val wrapped: AggregatePublisher[
194194
* Aggregates documents according to the specified aggregation pipeline, which must end with a `\$out` stage.
195195
*
196196
* [[https://www.mongodb.com/docs/manual/aggregation/ Aggregation]]
197-
* @return an empty Observable that indicates when the operation has completed
197+
* @return an Observable that indicates when the operation has completed.
198198
*/
199-
def toCollection(): SingleObservable[Void] = wrapped.toCollection()
199+
def toCollection(): SingleObservable[Unit] = wrapped.toCollection()
200200

201201
/**
202202
* Helper to return a single observable limited to the first result.

driver-scala/src/main/scala/org/mongodb/scala/ClientSessionImplicits.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ trait ClientSessionImplicits {
3535
*
3636
* A transaction can only be commmited if one has first been started.
3737
*/
38-
def commitTransaction(): SingleObservable[Void] = clientSession.commitTransaction()
38+
def commitTransaction(): SingleObservable[Unit] = clientSession.commitTransaction()
3939

4040
/**
4141
* Abort a transaction in the context of this session.
4242
*
4343
* A transaction can only be aborted if one has first been started.
4444
*/
45-
def abortTransaction(): SingleObservable[Void] = clientSession.abortTransaction()
45+
def abortTransaction(): SingleObservable[Unit] = clientSession.abortTransaction()
4646
}
4747

4848
}

driver-scala/src/main/scala/org/mongodb/scala/MapReduceObservable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ case class MapReduceObservable[TResult](wrapped: MapReducePublisher[TResult]) ex
216216
* Aggregates documents to a collection according to the specified map-reduce function with the given options, which must specify a
217217
* non-inline result.
218218
*
219-
* @return an empty Observable that indicates when the operation has completed
219+
* @return an Observable that indicates when the operation has completed
220220
* [[https://www.mongodb.com/docs/manual/aggregation/ Aggregation]]
221221
*/
222-
def toCollection(): SingleObservable[Void] = wrapped.toCollection()
222+
def toCollection(): SingleObservable[Unit] = wrapped.toCollection()
223223

224224
/**
225225
* Helper to return a single observable limited to the first result.

driver-scala/src/main/scala/org/mongodb/scala/MongoCollection.scala

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,44 +1328,44 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
13281328
/**
13291329
* Drops this collection from the Database.
13301330
*
1331-
* @return an empty Observable that indicates when the operation has completed
1331+
* @return an Observable that indicates when the operation has completed
13321332
* [[https://www.mongodb.com/docs/manual/reference/command/drop/ Drop Collection]]
13331333
*/
1334-
def drop(): SingleObservable[Void] = wrapped.drop()
1334+
def drop(): SingleObservable[Unit] = wrapped.drop()
13351335

13361336
/**
13371337
* Drops this collection from the Database.
13381338
*
13391339
* @param clientSession the client session with which to associate this operation
1340-
* @return an empty Observable that indicates when the operation has completed
1340+
* @return an Observable that indicates when the operation has completed
13411341
* [[https://www.mongodb.com/docs/manual/reference/command/drop/ Drop Collection]]
13421342
* @since 2.2
13431343
* @note Requires MongoDB 3.6 or greater
13441344
*/
1345-
def drop(clientSession: ClientSession): SingleObservable[Void] = wrapped.drop(clientSession)
1345+
def drop(clientSession: ClientSession): SingleObservable[Unit] = wrapped.drop(clientSession)
13461346

13471347
/**
13481348
* Drops this collection from the Database.
13491349
*
13501350
* @param dropCollectionOptions various options for dropping the collection
1351-
* @return an empty Observable that indicates when the operation has completed
1351+
* @return an Observable that indicates when the operation has completed
13521352
* [[https://www.mongodb.com/docs/manual/reference/command/drop/ Drop Collection]]
13531353
* @since 4.7
13541354
* @note Requires MongoDB 6.0 or greater
13551355
*/
1356-
def drop(dropCollectionOptions: DropCollectionOptions): SingleObservable[Void] = wrapped.drop(dropCollectionOptions)
1356+
def drop(dropCollectionOptions: DropCollectionOptions): SingleObservable[Unit] = wrapped.drop(dropCollectionOptions)
13571357

13581358
/**
13591359
* Drops this collection from the Database.
13601360
*
13611361
* @param clientSession the client session with which to associate this operation
13621362
* @param dropCollectionOptions various options for dropping the collection
1363-
* @return an empty Observable that indicates when the operation has completed
1363+
* @return an Observable that indicates when the operation has completed
13641364
* [[https://www.mongodb.com/docs/manual/reference/command/drop/ Drop Collection]]
13651365
* @since 4.7
13661366
* @note Requires MongoDB 6.0 or greater
13671367
*/
1368-
def drop(clientSession: ClientSession, dropCollectionOptions: DropCollectionOptions): SingleObservable[Void] =
1368+
def drop(clientSession: ClientSession, dropCollectionOptions: DropCollectionOptions): SingleObservable[Unit] =
13691369
wrapped.drop(clientSession, dropCollectionOptions)
13701370

13711371
/**
@@ -1413,24 +1413,24 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
14131413
*
14141414
* @param indexName the name of the search index to update.
14151415
* @param definition the search index mapping definition.
1416-
* @return an empty Observable that indicates when the operation has completed.
1416+
* @return an Observable that indicates when the operation has completed.
14171417
* @since 4.11
14181418
* @note Requires MongoDB 7.0 or greater
14191419
* @see [[https://www.mongodb.com/docs/manual/reference/command/updateSearchIndex/ Update Search Index]]
14201420
*/
1421-
def updateSearchIndex(indexName: String, definition: Bson): SingleObservable[Void] =
1421+
def updateSearchIndex(indexName: String, definition: Bson): SingleObservable[Unit] =
14221422
wrapped.updateSearchIndex(indexName, definition)
14231423

14241424
/**
14251425
* Drop an Atlas Search index given its name.
14261426
*
14271427
* @param indexName the name of the search index to drop.
1428-
* @return an empty Observable that indicates when the operation has completed.
1428+
* @return an Observable that indicates when the operation has completed.
14291429
* @since 4.11
14301430
* @note Requires MongoDB 7.0 or greater
14311431
* @see [[https://www.mongodb.com/docs/manual/reference/command/dropSearchIndex/ Drop Search Index]]
14321432
*/
1433-
def dropSearchIndex(indexName: String): SingleObservable[Void] = wrapped.dropSearchIndex(indexName)
1433+
def dropSearchIndex(indexName: String): SingleObservable[Unit] = wrapped.dropSearchIndex(indexName)
14341434

14351435
/**
14361436
* Get all Atlas Search indexes in this collection.
@@ -1569,39 +1569,39 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
15691569
*
15701570
* [[https://www.mongodb.com/docs/manual/reference/command/dropIndexes/ Drop Indexes]]
15711571
* @param indexName the name of the index to remove
1572-
* @return an empty Observable that indicates when the operation has completed
1572+
* @return an Observable that indicates when the operation has completed
15731573
*/
1574-
def dropIndex(indexName: String): SingleObservable[Void] = wrapped.dropIndex(indexName)
1574+
def dropIndex(indexName: String): SingleObservable[Unit] = wrapped.dropIndex(indexName)
15751575

15761576
/**
15771577
* Drops the given index.
15781578
*
15791579
* [[https://www.mongodb.com/docs/manual/reference/command/dropIndexes/ Drop Indexes]]
15801580
* @param indexName the name of the index to remove
15811581
* @param dropIndexOptions options to use when dropping indexes
1582-
* @return an empty Observable that indicates when the operation has completed
1582+
* @return an Observable that indicates when the operation has completed
15831583
* @since 2.2
15841584
*/
1585-
def dropIndex(indexName: String, dropIndexOptions: DropIndexOptions): SingleObservable[Void] =
1585+
def dropIndex(indexName: String, dropIndexOptions: DropIndexOptions): SingleObservable[Unit] =
15861586
wrapped.dropIndex(indexName, dropIndexOptions)
15871587

15881588
/**
15891589
* Drops the index given the keys used to create it.
15901590
*
15911591
* @param keys the keys of the index to remove
1592-
* @return an empty Observable that indicates when the operation has completed
1592+
* @return an Observable that indicates when the operation has completed
15931593
*/
1594-
def dropIndex(keys: Bson): SingleObservable[Void] = wrapped.dropIndex(keys)
1594+
def dropIndex(keys: Bson): SingleObservable[Unit] = wrapped.dropIndex(keys)
15951595

15961596
/**
15971597
* Drops the index given the keys used to create it.
15981598
*
15991599
* @param keys the keys of the index to remove
16001600
* @param dropIndexOptions options to use when dropping indexes
1601-
* @return an empty Observable that indicates when the operation has completed
1601+
* @return an Observable that indicates when the operation has completed
16021602
* @since 2.2
16031603
*/
1604-
def dropIndex(keys: Bson, dropIndexOptions: DropIndexOptions): SingleObservable[Void] =
1604+
def dropIndex(keys: Bson, dropIndexOptions: DropIndexOptions): SingleObservable[Unit] =
16051605
wrapped.dropIndex(keys, dropIndexOptions)
16061606

16071607
/**
@@ -1610,11 +1610,11 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
16101610
* [[https://www.mongodb.com/docs/manual/reference/command/dropIndexes/ Drop Indexes]]
16111611
* @param clientSession the client session with which to associate this operation
16121612
* @param indexName the name of the index to remove
1613-
* @return an empty Observable that indicates when the operation has completed
1613+
* @return an Observable that indicates when the operation has completed
16141614
* @since 2.2
16151615
* @note Requires MongoDB 3.6 or greater
16161616
*/
1617-
def dropIndex(clientSession: ClientSession, indexName: String): SingleObservable[Void] =
1617+
def dropIndex(clientSession: ClientSession, indexName: String): SingleObservable[Unit] =
16181618
wrapped.dropIndex(clientSession, indexName)
16191619

16201620
/**
@@ -1624,27 +1624,27 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
16241624
* @param clientSession the client session with which to associate this operation
16251625
* @param indexName the name of the index to remove
16261626
* @param dropIndexOptions options to use when dropping indexes
1627-
* @return an empty Observable that indicates when the operation has completed
1627+
* @return an Observable that indicates when the operation has completed
16281628
* @since 2.2
16291629
* @note Requires MongoDB 3.6 or greater
16301630
*/
16311631
def dropIndex(
16321632
clientSession: ClientSession,
16331633
indexName: String,
16341634
dropIndexOptions: DropIndexOptions
1635-
): SingleObservable[Void] =
1635+
): SingleObservable[Unit] =
16361636
wrapped.dropIndex(clientSession, indexName, dropIndexOptions)
16371637

16381638
/**
16391639
* Drops the index given the keys used to create it.
16401640
*
16411641
* @param clientSession the client session with which to associate this operation
16421642
* @param keys the keys of the index to remove
1643-
* @return an empty Observable that indicates when the operation has completed
1643+
* @return an Observable that indicates when the operation has completed
16441644
* @since 2.2
16451645
* @note Requires MongoDB 3.6 or greater
16461646
*/
1647-
def dropIndex(clientSession: ClientSession, keys: Bson): SingleObservable[Void] =
1647+
def dropIndex(clientSession: ClientSession, keys: Bson): SingleObservable[Unit] =
16481648
wrapped.dropIndex(clientSession, keys)
16491649

16501650
/**
@@ -1653,46 +1653,46 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
16531653
* @param clientSession the client session with which to associate this operation
16541654
* @param keys the keys of the index to remove
16551655
* @param dropIndexOptions options to use when dropping indexes
1656-
* @return an empty Observable that indicates when the operation has completed
1656+
* @return an Observable that indicates when the operation has completed
16571657
* @since 2.2
16581658
* @note Requires MongoDB 3.6 or greater
16591659
*/
16601660
def dropIndex(
16611661
clientSession: ClientSession,
16621662
keys: Bson,
16631663
dropIndexOptions: DropIndexOptions
1664-
): SingleObservable[Void] =
1664+
): SingleObservable[Unit] =
16651665
wrapped.dropIndex(clientSession, keys, dropIndexOptions)
16661666

16671667
/**
16681668
* Drop all the indexes on this collection, except for the default on _id.
16691669
*
16701670
* [[https://www.mongodb.com/docs/manual/reference/command/dropIndexes/ Drop Indexes]]
1671-
* @return an empty Observable that indicates when the operation has completed
1671+
* @return an Observable that indicates when the operation has completed
16721672
*/
1673-
def dropIndexes(): SingleObservable[Void] = wrapped.dropIndexes()
1673+
def dropIndexes(): SingleObservable[Unit] = wrapped.dropIndexes()
16741674

16751675
/**
16761676
* Drop all the indexes on this collection, except for the default on _id.
16771677
*
16781678
* [[https://www.mongodb.com/docs/manual/reference/command/dropIndexes/ Drop Indexes]]
16791679
* @param dropIndexOptions options to use when dropping indexes
1680-
* @return an empty Observable that indicates when the operation has completed
1680+
* @return an Observable that indicates when the operation has completed
16811681
* @since 2.2
16821682
*/
1683-
def dropIndexes(dropIndexOptions: DropIndexOptions): SingleObservable[Void] =
1683+
def dropIndexes(dropIndexOptions: DropIndexOptions): SingleObservable[Unit] =
16841684
wrapped.dropIndexes(dropIndexOptions)
16851685

16861686
/**
16871687
* Drop all the indexes on this collection, except for the default on _id.
16881688
*
16891689
* [[https://www.mongodb.com/docs/manual/reference/command/dropIndexes/ Drop Indexes]]
16901690
* @param clientSession the client session with which to associate this operation
1691-
* @return an empty Observable that indicates when the operation has completed
1691+
* @return an Observable that indicates when the operation has completed
16921692
* @since 2.2
16931693
* @note Requires MongoDB 3.6 or greater
16941694
*/
1695-
def dropIndexes(clientSession: ClientSession): SingleObservable[Void] =
1695+
def dropIndexes(clientSession: ClientSession): SingleObservable[Unit] =
16961696
wrapped.dropIndexes(clientSession)
16971697

16981698
/**
@@ -1701,21 +1701,21 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
17011701
* [[https://www.mongodb.com/docs/manual/reference/command/dropIndexes/ Drop Indexes]]
17021702
* @param clientSession the client session with which to associate this operation
17031703
* @param dropIndexOptions options to use when dropping indexes
1704-
* @return an empty Observable that indicates when the operation has completed
1704+
* @return an Observable that indicates when the operation has completed
17051705
* @since 2.2
17061706
* @note Requires MongoDB 3.6 or greater
17071707
*/
1708-
def dropIndexes(clientSession: ClientSession, dropIndexOptions: DropIndexOptions): SingleObservable[Void] =
1708+
def dropIndexes(clientSession: ClientSession, dropIndexOptions: DropIndexOptions): SingleObservable[Unit] =
17091709
wrapped.dropIndexes(clientSession, dropIndexOptions)
17101710

17111711
/**
17121712
* Rename the collection with oldCollectionName to the newCollectionName.
17131713
*
17141714
* [[https://www.mongodb.com/docs/manual/reference/commands/renameCollection Rename collection]]
17151715
* @param newCollectionNamespace the name the collection will be renamed to
1716-
* @return an empty Observable that indicates when the operation has completed
1716+
* @return an Observable that indicates when the operation has completed
17171717
*/
1718-
def renameCollection(newCollectionNamespace: MongoNamespace): SingleObservable[Void] =
1718+
def renameCollection(newCollectionNamespace: MongoNamespace): SingleObservable[Unit] =
17191719
wrapped.renameCollection(newCollectionNamespace)
17201720

17211721
/**
@@ -1724,12 +1724,12 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
17241724
* [[https://www.mongodb.com/docs/manual/reference/commands/renameCollection Rename collection]]
17251725
* @param newCollectionNamespace the name the collection will be renamed to
17261726
* @param options the options for renaming a collection
1727-
* @return an empty Observable that indicates when the operation has completed
1727+
* @return an Observable that indicates when the operation has completed
17281728
*/
17291729
def renameCollection(
17301730
newCollectionNamespace: MongoNamespace,
17311731
options: RenameCollectionOptions
1732-
): SingleObservable[Void] =
1732+
): SingleObservable[Unit] =
17331733
wrapped.renameCollection(newCollectionNamespace, options)
17341734

17351735
/**
@@ -1738,14 +1738,14 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
17381738
* [[https://www.mongodb.com/docs/manual/reference/commands/renameCollection Rename collection]]
17391739
* @param clientSession the client session with which to associate this operation
17401740
* @param newCollectionNamespace the name the collection will be renamed to
1741-
* @return an empty Observable that indicates when the operation has completed
1741+
* @return an Observable that indicates when the operation has completed
17421742
* @since 2.2
17431743
* @note Requires MongoDB 3.6 or greater
17441744
*/
17451745
def renameCollection(
17461746
clientSession: ClientSession,
17471747
newCollectionNamespace: MongoNamespace
1748-
): SingleObservable[Void] =
1748+
): SingleObservable[Unit] =
17491749
wrapped.renameCollection(clientSession, newCollectionNamespace)
17501750

17511751
/**
@@ -1755,15 +1755,15 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
17551755
* @param clientSession the client session with which to associate this operation
17561756
* @param newCollectionNamespace the name the collection will be renamed to
17571757
* @param options the options for renaming a collection
1758-
* @return an empty Observable that indicates when the operation has completed
1758+
* @return an Observable that indicates when the operation has completed
17591759
* @since 2.2
17601760
* @note Requires MongoDB 3.6 or greater
17611761
*/
17621762
def renameCollection(
17631763
clientSession: ClientSession,
17641764
newCollectionNamespace: MongoNamespace,
17651765
options: RenameCollectionOptions
1766-
): SingleObservable[Void] =
1766+
): SingleObservable[Unit] =
17671767
wrapped.renameCollection(clientSession, newCollectionNamespace, options)
17681768

17691769
/**

0 commit comments

Comments
 (0)