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

2.x - CombineLatestDelayError throwing error before subscribing other observables #5558

Closed
saiimons opened this issue Aug 22, 2017 · 3 comments
Milestone

Comments

@saiimons
Copy link

I am working on a piece of code where I basically have a cached value, which I want to combine with other data and update from the network.

My thought was using combineLatestDelayError and magic would happen! Except when the network is down... Even though I have valid values in both my observables I only end up getting the error.

I narrowed it down to a simple test case:

    @Test
    public void combineLatestDelayErrorFailure() {
        final int result = Observable.combineLatestDelayError(
                Arrays.asList(
                        Observable.just(41).concatWith(Observable.error(new Exception("Failure"))),
                        Observable.just(1).delay(1, TimeUnit.SECONDS)
                ),
                ints -> ((int) ints[0]) + ((int) ints[1])
        ).blockingFirst();
        assertThat(result).isEqualTo(42);
    }

It always throws the Exception.

There is one point in the documentation about the calls being synchronous, though it is not clear to me how I could make changes to my observables to avoid that situation 😿

@saiimons saiimons changed the title [2.0.x/2.1.x] CombineLatestDelayError throwing error before subscribing other observables 2.x - CombineLatestDelayError throwing error before subscribing other observables Aug 22, 2017
@akarnokd akarnokd added this to the 2.2 milestone Aug 22, 2017
@akarnokd
Copy link
Member

Thanks for reporting, this is a bug with the operator not properly considering the DelayError setting in this synchronous situation. I can't give you a simple workaround; you could try and materialize the failing source and the combiner function could throw it via Exceptions.wrapOrThrow().

I'll post a fix for the operator shortly.

@akarnokd
Copy link
Member

Closing via #5560.

@saiimons
Copy link
Author

Thanks @akarnokd I'll wait for the next release to have this fixed!

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

No branches or pull requests

2 participants