Skip to content

Commit c493ed7

Browse files
committed
Reactive Publisher to Monix extensions for typed Mongo - comments
1 parent 3285959 commit c493ed7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mongo/jvm/src/main/scala/com/avsystem/commons/mongo/reactive/ReactiveMongoExtensions.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ object ReactiveMongoExtensions extends ReactiveMongoExtensions {
2121
// mongo observable implementation sometimes logs an error on server-closed cursors
2222
private def singleObservable: Task[Option[T]] = Task.fromReactivePublisher(publisher)
2323

24-
def headOptL: Task[Opt[T]] = singleObservable.map(_.toOpt)
24+
// handles both an empty Publisher and and a single null item
2525
def headOptionL: Task[Option[T]] = singleObservable.map(_.filterNot(_ == null))
26+
def headOptL: Task[Opt[T]] = headOptionL.map(_.toOpt)
27+
// can return null if Mongo driver for some reason returns null, intentionally don't want to report failure
2628
def headL: Task[T] = singleObservable.map(_.get)
27-
def completedL: Task[Unit] = singleObservable.void
29+
def completedL: Task[Unit] = headOptionL.void
2830
}
2931
}

0 commit comments

Comments
 (0)