opened
passsy
username_0
Targets issue #5237 where an `Exception` in `onSuccess` of an async `Single` wasn't forwarded to `onError`. For a sync `Single` it already gets forwarded correctly.

Example:
```java
Single.just("test")
        .delay(1, TimeUnit.MILLISECONDS)
        .subscribe(
        result -> {
            System.out.println("got text: " + result);
            throw new IllegalStateException("single async something is wrong");
            // onError will not be called, hard crash
        },
        e -> {
            // not called
            System.out.println("caught error " + e.getMessage());
            e.printStackTrace();
        });
```

I introduced `SafeSingleSubscriber` analog to `SafeSubscriber` of `Observable`. It makes sure `onError` gets called when `onSuccess` throws.

I had to introduce `private Subscription unsafeSubscribe(SingleSubscriber)` for internal usage of `Single#subscribeOn()` and `Single#unsubscribeOn()` which should *not* be wrapped by `SafeSingleSubscriber`.

Furthermore I added the `subscriber.isUnsubscribed()` case in all three `subscribe` methods analog to `Observable#subscribe`
```java
    // ...
    if (subscriber.isUnsubscribed()) {
        RxJavaHooks.onError(RxJavaHooks.onSingleError(e));
    } else {
        // try forwarding error to subscriber
    }
    // ....
```
as well as `Single#subscribe` now throws `OnErrorFailedException` instead of `RuntimeException` when calling `subscriber.onError(e)` fails.

`Single.using` is now working correctly, I uncommented the missing assertions
1.x fix async single error report (bug #5237)
issue
created
passsy
username_0
What can I say, tests are working on my maschine 😅 Is it normal that rx1 tests are flaky?

```
pascalwelsch$ ./gradlew test
...
BUILD SUCCESSFUL

Total time: 3 mins 54.445 secs
```
comment
created
passsy
username_0
I tried to revert to the behaviour in `1.1.9`. I have some problems upgrading because of this behaviour change of not calling `onError` introduced in `1.2.2`. Especially frustrating because this is the behaviour for synchronous Singles but changes when adding a `delay`.

What about those `Single.using` tests? They are now working correctly as far as I understand. Is the change of those assertions intended?

I'll try to change the PR without changing the current behaviour.
comment
created
akarnokd
username_1
The current (unsafe)subscribe doesn't call unsubscribe. The rest of the test is still valuable.
comment
created
akarnokd
username_1
It's much cleaner if you start over.
comment
created
passsy
username_0
Was building in the complete wrong direction
~close
comment