Since RxJava modifies exceptions during call of getCause method of CompositeException instance and connect these exceptions in chains we have finally millions of exceptions and quickly getting out of memory.
@Test
public void compositeExceptionIssue() {
Single
.just(new Throwable("ROOT ERROR"))
.flatMapCompletable(rootError -> Observable
.range(1, 10)
.flatMapCompletable(testNumber -> Completable
.mergeArrayDelayError(
Completable.error(new RuntimeException("Test#" + testNumber + "A", rootError)),
Completable.error(new RuntimeException("Test#" + testNumber + "B", rootError))
)
.doOnError(Throwable::getCause)
.onErrorComplete()
)
.doOnComplete(() -> {
rootError.printStackTrace();
})
)
.blockingAwait();
}
This simple test demonstrates that cause of rootError throwable is changed.