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

flatMap stackoverflow on 1-to-1 function

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.0
    • Fix Version/s: None
    • Component/s: API
    • Labels:
      None
    • Sprint:
      JVM Sprint 40

      Description

      The following bit of code will result in a stack overflow:

      {
          val count = 10e6 toInt ;
          Observable (1 to count) flatMap (i => Observable(Seq(i))) subscribe  new Observer[Int] {
            override def onNext(result: Int): Unit = {}
            override def onError(e: Throwable): Unit = ???
            override def onComplete(): Unit = println("done")
          }
       }
      

      Results in the following recursive call stack:
      {{ at scala.Option.foreach(Option.scala:257)
      at org.mongodb.scala.internal.FlatMapObservable$$anon$1$$anon$3.onComplete(FlatMapObservable.scala:84)
      at org.mongodb.scala.internal.IterableObservable$$anon$1.request(IterableObservable.scala:44)
      at org.mongodb.scala.internal.FlatMapObservable$$anon$1$$anon$3.onSubscribe(FlatMapObservable.scala:75)
      at org.mongodb.scala.internal.IterableObservable.subscribe(IterableObservable.scala:24)
      at org.mongodb.scala.internal.FlatMapObservable$$anon$1.onNext(FlatMapObservable.scala:66)
      at org.mongodb.scala.internal.SubscriptionCheckingObserver.onNext(SubscriptionCheckingObserver.scala:33)
      at org.mongodb.scala.internal.IterableObservable$$anon$1.request(IterableObservable.scala:39)
      at org.mongodb.scala.internal.FlatMapObservable$$anon$1$$anon$2.request(FlatMapObservable.scala:46)
      at org.mongodb.scala.internal.FlatMapObservable$$anon$1$$anon$3$$anonfun$onComplete$1.apply(FlatMapObservable.scala:84)
      at org.mongodb.scala.internal.FlatMapObservable$$anon$1$$anon$3$$anonfun$onComplete$1.apply(FlatMapObservable.scala:84)}}

      The culprit appears to be flatMap().

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: