2.x: improve BaseTestConsumer with awaitCount & timeout #5155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enhances the timeout detection and reporting of the
TestSubscriber/TestObserverbase classBaseTestConsumer:awaitCount(int atLeast [, Runnable waitStrategy [, timeout]]): wait until at least the given amount of onNext events have been observed or the upstream terminated.awaitXmethods to set atimeoutflag.timeout!string in the assertion failures set by theawaitXmethods.disposed!string in the assertion failures if the consumer has been cancelled/disposed.assertTimeoutandassertNoTimeoutto assert explicitly after anawaitXmethod.isTimeoutandclearTimeoutto check and clear the flag status.In addition, the internal array that collects the items has been replaced with a new custom
Listimplementation:VolatileSizeArrayListthat makes suresize()is a volatile read and happens before the committing the size in another thread due toadd(). (In theory, one shouldn't castvalues()unconditionally toArrayListanyway.)