-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
When a subscriber throws an exception during onNext, the subscriber will be unsubscribed and will not receive any more values (RxJava 1.x).
Example code:
private void wireInternally() {
v2vm_submitButtonEvents
.map(actionEvent -> new NameFirstname(v2vm_name.getValue(), v2vm_firstname.getValue()))
.subscribe(vm2m_nameFirstname);
}
Let's change this code to "throw up sometimes":
private final AtomicInteger counter= new AtomicInteger(0);
private void wireInternally() {
v2vm_submitButtonEvents
.map(actionEvent -> {
if (counter.incrementAndGet() == 3) {
throw new RuntimeException("boom");
}
return new NameFirstname(v2vm_name.getValue(), v2vm_firstname.getValue());
})
.subscribe(vm2m_nameFirstname);
}
As soon as we reach counter value 3
, the "flow" will automatically stop. The map
function is automatically unsubscribed from v2vm_submitButtonEvents
.
The application doesn't respond anymore and does not recover.
This is kind of horrible, because the chance to see those issues is high and you will probably discover them very late (in production).
Possible workarounds:
- add the
retry
operator "somewhere" - add try/catch blocks
Needs more investigation for a clean solution.
Metadata
Metadata
Assignees
Labels
No labels