Version: 3.0.0
Hello! In the ConnectableObservable java docs this following is written:
Disposing the connection will reset the {@code ConnectableFlowable} to its fresh state and there is no need to call {@code reset()} in this case.
So I think If I dispose the connection then I don't need to call reset, it should be in its initial state. However the following test fails. But if you uncomment the reset() call then it passes:
@Test
fun testReplay() {
val subject = PublishSubject.create<Int>()
val replay = subject.replay()
var observer = replay.test() // subscribe
val disposable = replay.connect() // connect
subject.onNext(1)
observer.dispose() // unsubscribe
disposable.dispose() // disconnect
// sharedStream.reset()
observer = replay.test() // subscribe again
replay.connect() // connect again
subject.onNext(0)
observer.assertValues(0) // Actual value is 1, but if reset was called then it will be 0
}
Could you please clarify whether it is a bug or expected behaviour. Thanks!
At glance, looks like it is an oversight as publish works as documented. I'll have to check if there is another reason for it such as an (older) unit test expecting some behavior.
Thanks for the reporting. This is a bug in the replay operator as it was supposed to reset upon dispose, but the code was never enabled for it, nor was the behavior actually tested. Posted a fix in #6921
@akarnokd Thanks for the fix! Are there any snapshots available with this fix? I see there were to releases of the 2.x version with bug fixes, but this fix was skipped for some reason. The latest version I could find is 3.0.0.