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.replay - a bug or a feature? #6920

Closed
arkivanov opened this issue Feb 28, 2020 · 4 comments · Fixed by #6921
Closed

Observable.replay - a bug or a feature? #6920

arkivanov opened this issue Feb 28, 2020 · 4 comments · Fixed by #6921

Comments

@arkivanov
Copy link

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!

@akarnokd
Copy link
Member

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.

@akarnokd
Copy link
Member

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

@arkivanov
Copy link
Author

@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.

@akarnokd
Copy link
Member

#6929
https://github.com/ReactiveX/RxJava#snapshots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants