Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observable.zip throws exception on complete #144

Closed
alexandru opened this Issue Apr 27, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@alexandru
Copy link
Member

alexandru commented Apr 27, 2016

Signaled by @cranst0n on April 26, 2016 8:15 PM:

import monix.reactive.Observable
import monix.execution.Scheduler.Implicits.global

val obs0 = Observable.fromIterable(Array(Array(1, 2), Array(2, 3)))
val obs1 = Observable.fromIterable(Array(Array(4, 5), Array(5, 6)))
val obs2 = Observable.fromIterable(Array(Array(7, 8), Array(8, 9)))

val obsVec = Vector(obs0, obs1, obs2)
val zipped = Observable.zipList(obsVec: _*).map(_.flatten)

zipped.foreach(x => println(x.mkString(",")))

This sample triggers an error:

Ian McIntosh @cranst0n Apr 26 18:35
This is my first attempt:
observables.foldLeft(Observable.repeat(Array.empty[Int]))(_.zipWith(_)(_ ++ _))
but it blows up with:
java.lang.IllegalStateException: Promise already completed.
    at scala.concurrent.Promise$class.complete(Promise.scala:55)
    at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153)
    at scala.concurrent.Promise$class.success(Promise.scala:86)
    at scala.concurrent.impl.Promise$DefaultPromise.success(Promise.scala:153)
    at monix.reactive.internal.builders.Zip2Observable.monix$reactive$internal$builders$Zip2Observable$$signalOnComplete$1(Zip2Observable.scala:126)
    at monix.reactive.internal.builders.Zip2Observable$$anon$1.onComplete(Zip2Observable.scala:151)
    at monix.reactive.internal.builders.Zip2Observable.monix$reactive$internal$builders$Zip2Observable$$rawOnComplete$1(Zip2Observable.scala:104)
    at monix.reactive.internal.builders.Zip2Observable$$anonfun$monix$reactive$internal$builders$Zip2Observable$$signalOnComplete$1$1.apply(Zip2Observable.scala:120)
    at monix.reactive.internal.builders.Zip2Observable$$anonfun$monix$reactive$internal$builders$Zip2Observable$$signalOnComplete$1$1.apply(Zip2Observable.scala:118)

This was a stupid mistake brought to life because of a race condition.

alexandru added a commit that referenced this issue Apr 27, 2016

@alexandru

This comment has been minimized.

Copy link
Member Author

alexandru commented May 2, 2016

Fixed in 2.0-RC2.

@alexandru alexandru closed this May 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.