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

Collect not working after flatMap

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 2.0.0
    • Component/s: None
    • Labels:
      None
    • Sprint:
      JVM Sprint 37, JVM Sprint 38

      Description

      Hi, after using "collect()", flatMap doesn't work (doesn't get values, complete or even fail).

      Inside "driver/src/test/scala/org/mongodb/scala/internal/ScalaObservableSpec.scala" you can add the following cases to reproduce the bug:

        it should "read all values of a flatmapped collected observable" in {
          var results = ArrayBuffer[Int]()
       
          observable[Int]()
            .collect()
            .flatMap(_ => Observable(1 to 3))
            .subscribe((i: Int) => results += i)
       
          results should equal(1 to 3)
        }
       
        it should "finish with error on a flatmapped collected observable" in {
          var errorSeen: Option[Throwable] = None
       
          observable[Int](fail = true)
            .collect()
            .flatMap(_ => Observable(1 to 3))
            .subscribe((s: Int) => (), (fail: Throwable) => errorSeen = Some(fail))
       
          errorSeen.getOrElse(None) shouldBe a[Throwable]
        }
       
        it should "complete a flatmapped collected observable" in {
          var completed = false
       
          observable[Int]()
            .collect()
            .flatMap(_ => Observable(1 to 3))
            .subscribe((s: Int) => (), (t: Throwable) => t, () => completed = true)
       
          completed should equal(true)
        }
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: