Skip to content

Data loss with RetryWithPredicate as compared to Retry Infinite #3008

Closed
@stealthcode

Description

@stealthcode

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions