question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

2.x: .zipWith() with the same shared source crashes the app

See original GitHub issue

The following code crashes the app with a IllegalStateException (using version 2.1.3):

        Observable myObservable = Observable.just(1)
            .flatMap(i -> {
                throw new IllegalStateException();
            }).share();

        myObservable
            .zipWith(myObservable, Pair::new)
            .subscribe(pair -> {
                //ignore
            }, throwable -> {
                //ignore
            });

If I comment the .zipWith(myObservable, Pair::new) line, then everything works. Is that the expected behavior?

In trying to investigate the issue, the PublishObserver object on onError(Throwable e) loops through 2 inner disposables, both containing the same instance of ZipCoordinator.

The first time the publish observer propagates the error to inner.child.onError(e), the zip coordinator sets itself to 0 on innerError(...):

        void innerError(Throwable ex, int index) {
            if (getAndSet(0) > 0) {
                disposeExcept(index);
                actual.onError(ex);
            } else {
                RxJavaPlugins.onError(ex);
            }
        }

But since inner.child.onError(e) is called again, it gets propagated to RxJavaPlugins.onError(ex); and crashes the app. It seems to me since this is a shared source, that the error should be propagated only once, no?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
riclagecommented, Sep 6, 2017

The original reactive concept defines max one error per Observer and we can’t do much about that

I agree but then the error should be propagated down from the .zipWith() like I tried here. As it is in my original example, I have “one” observer but RxJava is trying to propagate the same error twice.

0reactions
akarnokdcommented, Sep 6, 2017

The original reactive concept defines max one error per Observer and we can’t do much about that: we either drop it, send it to some handler or the user doesn’t let an exception bubble back into RxJava. That’s what io.reactivex.Notification<T> should allow you: turning an error into an item.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What can we do about a randomly crashing app without ...
This VB6 DLL is kicked off by 2-3 function calls from a VB Script. Obviously, I can modify the VB Script to add...
Read more >
App Crash when using print of UIPrintInteractionController
I created a new iOS App running it on Simulator iPhone 12/iOS 15 with the following code: let a4Document = Bundle.main.url(forResource: "A4" ...
Read more >
SciDAVis Activity - SourceForge
Today, I received a notice from my anti-virus software in the newly installed scidavis app. Is this right? Does anyone else got similar...
Read more >
AppDynamics App iQ Platform AppDynamics Platform
The app server agent collects metrics about applications and identifies applications, tiers, and nodes with slow transactions,.
Read more >
6 Troubleshoot System Crashes - Java - Oracle Help Center
Crashes caused by bugs in the Java HotSpot VM or in the Java SE library code are rare. This chapter provides suggestions about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found