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

Unsubscribed buffer continues producing #559

Closed
pjan opened this issue Dec 4, 2013 · 5 comments
Closed

Unsubscribed buffer continues producing #559

pjan opened this issue Dec 4, 2013 · 5 comments

Comments

@pjan
Copy link

pjan commented Dec 4, 2013

version 0.15.1

I don't know whether this is expected behaviour, but I believe it isn't since it's verry counterintuitive to me.

e.g., in the scala repl

import rx.lang.scala.Observable
import scala.concurrent.duration._

val obs = Observable.interval(100 millis).map(_ => scala.util.Random.nextInt(8))
val bObs = obs.buffer(2 seconds, 1 second)
val subs = bObs.subscribe(x => println(x))
subs.unsubscribe()

Eventually, the subscribtion/bObs continues producing empty Buffers (outputting them in the repl), whereas I would expect this to stop...

@samuelgruetter
Copy link
Contributor

Indeed, here's something wrong.

This snippet

val obs = Observable.never
val bObs = obs.buffer(200 millis, 100 millis)
val subs = bObs.subscribe(x => println(x))
println("subscribed")
Thread.sleep(1000)
println("unsubscribed")
Thread.sleep(2000)

outputs

subscribed
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
unsubscribed
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()
Buffer()

which is wrong: After unsubscribe, there should be no more Buffers. I think the problem is that on this line, the returned subscription will not call the TimeBasedChunkCreator.stop method.

@pjan
Copy link
Author

pjan commented Dec 4, 2013

You're forgetting the subs.unsubscribe call in your snippet, but the issue remains. For that matter: same unexpected behaviour with window, where production continues after calling unsubscribe

val obs = Observable.never
val bObs = obs.window(200 millis, 100 millis)
val subs = bObs.subscribe(x => println(x))
println("subscribed")
Thread.sleep(1000)
subs.unsubscribe
println("unsubscribed")
Thread.sleep(2000)

@samuelgruetter
Copy link
Contributor

@pjan LOL yes you're right ;-)

@filipelenfers
Copy link

Same thing happening with me! :) The subscription continues to run, but receiving empty buffers, after using unsubscribe.

@benjchristensen
Copy link
Member

Fixed in #596

jihoonson pushed a commit to jihoonson/RxJava that referenced this issue Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants