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

Data loss with RetryWithPredicate as compared to Retry Infinite #3008

Closed
stealthcode opened this issue Jun 5, 2015 · 4 comments
Closed

Data loss with RetryWithPredicate as compared to Retry Infinite #3008

stealthcode opened this issue Jun 5, 2015 · 4 comments
Labels

Comments

@stealthcode
Copy link

The following test fails once when mapping 3 values. The subscribe only receives 2 values.

final AtomicBoolean isFirst = new AtomicBoolean(true);
Observable.<Long> just(1L, 2L, 3L).map((Long x) -> {
    System.out.println("map " + x);
    if (x == 2 && isFirst.getAndSet(false)) {
        throw new RuntimeException("retryable error");
    }
    return x;
})
.retry((i, t) -> {return true;})
.forEach(System.out::println);

output

map 1
1
map 2
map 3
3

When you replace .retry((i, t) -> {return true;}) with the retry infinite retry() then the output looks like this...

map 1
1
map 2
map 1
1
map 2
2
map 3
3
@akarnokd
Copy link
Member

akarnokd commented Jun 5, 2015

/cc @davidmoten

@davidmoten
Copy link
Collaborator

Yep, I'll have a look at it in the next couple of days. @stealthcode I'll check it with #2997 which is looking to address a few retry issues.

davidmoten added a commit to davidmoten/RxJava that referenced this issue Jun 8, 2015
@davidmoten
Copy link
Collaborator

I've tested these with #2997 and they both pass.

The emissions are for retry with always true predicate:

map 1
1
map 2
map 3
map 1
1
map 2
2
map 3
3

and for infinite retry:

map 1
1
map 2
map 1
1
map 2
2
map 3
3

The emissions are the same and are expected. I'm unsure why the extra line map 3 occurs in the logging of retry with predicate but might be worth checking.

I'll commit the two new unit tests (in OperatorRetryWithPredicateTest) to the #2997 PR.

@akarnokd akarnokd added the Bug label Jun 10, 2015
@stealthcode
Copy link
Author

This seems to be fixed in the latest 1.x

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

No branches or pull requests

3 participants