Skip to content

Unsubscription due to missing exception handling (e.g. binders) -> application gets unresponsive #7

Description

@Petikoch

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions