Uploaded image for project: 'Scala'
  1. Scala
  2. SCALA-457

Observable flatMap combined with filter never completes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.0
    • Component/s: None
    • Labels:
      None

      Description

      I ran into this issue when working with an actual MongoDB Observable, but it's easy to reproduce just using in-memory Observables as well.

       

      Running the following code will result in the future timing out (i.e. the observable never completing)

      val observable = Observable(1 to 10)
      val future = observable
        .filter(_ % 2 == 0)
        .flatMap(v => Observable(List(v)))
        .toFuture()
       
      // This call will time out
      println(Await.ready(future, 10.seconds)) 

      Removing the filter call will resolve it (in that it will complete), but of course it means that no filtering will be done

       val observable = Observable(1 to 10)
          val future = observable
      //      .filter(_ % 2 == 0)
            .flatMap(v => Observable(List(v)))
            .toFuture()
       
          // This works
          println(Await.ready(future, 10.seconds)) 

      As mentioned above, this is also a problem when using an Observable based on a MongoDB find call for example.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: